Reply to SQL relationships and identities

Your name:

Reply:


Posted by Mike on 12/07/05 18:16

Can anyone tell me what is best practices to define relationships between
tables and to define their primary key?

For example...
One table is Orders and other is OrderDetails.
For ease of accessing datas from table OrderDetails I have fields copied
from Orders like year_of_order, order_number, client_id.

Now, is it better to link those tables on this three fields, because they
are already there or define new field in OrderDetails with name OrderID and
link it on ID field from table Orders?
In this case I will always access table Orders to check year of order,
order number or client id for records in OrderDetails.

Which one of these examples have better performace on server?

I'm also doubting is it good to define field Id in each table and use it
for relationships to other tables or link tables on fields like
Number_of_order.

Is it enough to define field "Id" set it as PK and Identity Seed 1 for
unique mark of record and preserving consistency of data.

Is it good practice to link tables on primary key from one table to other
column in other table?

Thnks.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация