database - MySQL making a relationship table for different objects -


so, i'm in dilema.

wich best approach solve problem:

i deal dozens of diferent tables, each 1 representing different entity , having @ least 1 unique primary key. (unique in context of table itself, means it's not guaranteed 1 unique value in 1 table doesn't exists in another)

my mission create intermediate table(s) establish relationship of 1 'object' in table another. (something similar parent/child relationship).

some of these tables may have hundreds or thousands rows main 1 may around 1 million.

in of cases relation between 2 'objects' one-to-one. there's special cases 1 object may linked 2 or more objects.

so come 2 different approaches:

table1) create table know there's single child/parent(s) relationship

----------------------------------------------------- | child | parentida | parentidb | ... | parentidn | ----------------------------------------------------- 

table 2) create table represent relation of children/parents:

----------------------------------------------- | child | typeofchild | parent | typeofparent | ----------------------------------------------- 

these tables exclusive. relations stored in 1 table maybe not exists on other. in other words, relations of objects of typea typen may arbitrarily stored in 1 of these 2 tables. , decision of search in 1 of 2 tables should hardcoded.

i prefer use second option only. data in single table, way i'll end 50 million+ table, wich may cause performance trouble.

so, using first table may able store data more efficiently.

given expirience, in right path? wich sollution may more appropriate store, maintain performance?

note: in table 2 "typeof" necessary preserve ids identity.

thx,

fkk03d057


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -