nested attributes - Implement 1:N relation in postgreSQL (object-relational) -
nested attributes - Implement 1:N relation in postgreSQL (object-relational) -
i'm struggling postgresql, don't know how link 1 instance of type a set of instances of type b. i'll give brief example:
let's want set db containing music albums , people, each having list of favorite albums. define types that:
create type album_t ( artist varchar(50), title varchar(50) ); create type person_t ( firstname varchar(50), lastname varchar(50), favalbums album_t array[5] );
now want create tables of types:
create table person of person_t oids; create table album of album_t oids;
now want create db object-realational gets, don't want nest album "objects" in row favalbums of table person, want "point" entries in table album, n person records can refer same album record without duplicating on , over.
i read manual, seems lacks vital examples object-relational features aren't beingness used often. i'm familiar realational model, want utilize tables relations.
thanks in advance! das_weezul
now want create db object-realational gets, don't want nest album "objects" in row favalbums of table person, want "point" entries in table album, n person records can refer same album record without duplicating on , over.
drop array column, add together id primary key column (serial type) each table, drop oids (note manual recommends against using them). , add together favoritealbum table 2 columns (personid, albumid), latter of primary key. (your relation n-n, not 1-n.)
postgresql nested-attributes object-relational-model
Comments
Post a Comment