Reply to Re: 2 different foreign keys in one table

Your name:

Reply:


Posted by David Portas on 06/13/06 20:09

HandersonVA wrote:
> There is itemlookup table, which stores item number and item
> description. Also there is a child table, pricehistory, of the
> itemlookup table, which stores different prices and different date
> ranges. So it is one-to-many relationship. (Price can be stored more
> than one with a different date range)
> And there is another table RequestItem that stores the foreign key of
> the itemlookup table to show the information of the itemlookup table.
> Then how do I know later which date range of the price was stored in
> the RequestItem table? Since I only keep the foreign key of the
> itemlookup table, it will be impossible to keep track of the row of the
> pricehistory table if there are more than one data existed in the
> pricehistory table.
> Will it be a valid table structure to create a column for the foreign
> key of the pricehistory in RequestItem table or any other ways to
> handle this issue?

It sounds like RequestItem may need to include the date or some other
key that references PriceHistory. It isn't obvious whether RequestItem
would also require a foreign key on the Item table. Please post DDL
instead of long narratives, then we won't have to guess. There is
nothing logically wrong with having two foreign keys on one table
however.

--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--

[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

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