Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- storing varying data types in a (postgresql) database
- CREATE TABLE key_values(user_id integer references users(id), key varchar(255), type varchar(255), CONSTRAINT UNIQUE(user_id, key));
- CREATE TABLE key_values_int(value integer) INHERITS (key_values);
- CREATE TABLE key_values_string(value varchar(255)) INHERITS (key_values);
- and so on...
- CREATE INDEX tbl_col_propx_idx ON tbl (cast(col AS int))
- WHERE prop_type_id = 23; -- 23 signifying "propertyX"
- CREATE TABLE prop_type(
- prop_type_id int PRIMARY KEY,
- prop_type text NOT NULL);
- SELECT *
- FROM tbl
- WHERE prop_type_id = 23 -- 23 signifying "propertyX"
- AND col::int BETWEEN 50 AND 100
Advertisement
Add Comment
Please, Sign In to add comment