sql - How to query a One to Many to Many to One to Many to One and match info from the first table, and the last table? -
i have table 1 many on cross ref table, many 1 on table. table has 1 many on table , there 1 1 between table.
so think of this:
people -> crossref <- dog breeds -> many different dogs -> dog name
and want associate person -> dog name no duplication of same dog name per person.
like how many distinct dog names person use. , don't want utilize distinct because slow. want query instant or near instant. obvious selection alter info model cross ref between people , dog names, lets pretend not option. tables have indexed ids person.id, etc.
your erd incorrect. instead should read follows:
person <1:m> dog <1:1 or 1:m> dog breed
a person owns 1 or many dogs. dog of single breed (well, guess can create one-to-many if consider mixed muts). design, can reply person owns dogs , various breeds. in design above, there not natural relationship between person , breed.
sql oracle plsql rdbms
No comments:
Post a Comment