CREATE TABLE person_properties (
  person_id INT,  
  key TEXT,
  value TEXT,
  PRIMARY KEY (person_id, key)
);
CREATE TABLE persons (
  id SERIAL PRIMARY KEY
);
I've done this:
INSERT INTO persons DEFAULT_VALUES;  -- suppose id is 1
INSERT INTO person_properties (person_id, key, value) VALUES (1, 'age', '30')
INSERT INTO person_properties (person_id, key, value) VALUES (1, 'weight', '20lb')
I'd like to select persons with age and weight as columns, with the values from person_properties (or NULL if it doesn't exist). How can I do this?
 
    