I am designing a database for a web site, where performance is the top most priority.
the key functionality is based around two tables.
and these table have many-to-many relations ship.
to split this, i have added an extra table Table1_Table2 that then holds teh combination of both tabl’e primary key on per relation basis.
e.g.
I have all my cars in Car table, and all my colors in color table
CarTable
ID(PK) – Name
1 – BMW
2 – Mercedes
3 – VW
4 – AUdi
ColorTable
ID(PK) – Color
1 – Blue
2 – Green
3 – Black
4 – Yellow
for many-to-many relation i have done this:
Car_ColorTable
ID(PK) – CarID – ColorID
1 – 1 – 2
2 – 1 – 4
3 – 2 – 4
4 – 3 – 1
5 – 4 – 1
6 – 4 – 3
7 – 4 – 3
is this a good design considering:
1) performance is the top priority.
2) the tables will have huge amount of data (more than 1 million records in both tables, and you can imagine how many rows will end up in Car_ColorTable.
if the above design is not the solution, how should i design this?
it should be
Car_ColorTable
you dont want the id column there,
primary key should have both columns
you can create similar non clustered index with columns in oposite order that mean (ColorID, CarID)
and thats it