|
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]
|