Reply to Re: identity column

Your name:

Reply:


Posted by Erland Sommarskog on 06/08/05 00:54

Sam (samuel.berthelot@voila.fr) writes:
> Maybe it's clearer with my tables. Here are the ones concerned with
> only the relevant fields:
>
> User(UserId)
> Web(WebId)
> Query(QueryId)
> UserQueries(UserId, WebId, QueryId)
>
> UserQueries is the trouble maker. Right now (UserId, WebId, QueryId)
> are FK and PK at the same timefor this table. They must be FK anyway,
> but wouldn't it be better to have something like:
>
> UserQueries(UserQueriesId, UserId, WebId, QueryId)
>
> with userQueriesId being Identity type ?

It could be, but I say that the odds are poor. Unless you really some
use which mandates a surrogate key, there is no reason to have any
UserQueriesId.

If you add an IDENTITY column you should still create a UNIQUE constraint
for (UserId, WebId, QueryId).


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp

[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

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