Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #1685 > unrolled thread

More about relationship in a database

Started by"Tony Johansson" <johansson.andersson@telia.com>
First post2014-02-16 18:26 +0100
Last post2014-02-16 19:42 +0100
Articles 2 — 2 participants

Back to article view | Back to comp.databases.ms-sqlserver


Contents

  More about relationship in a database "Tony Johansson" <johansson.andersson@telia.com> - 2014-02-16 18:26 +0100
    Re: More about relationship in a database Erland Sommarskog <esquel@sommarskog.se> - 2014-02-16 19:42 +0100

#1685 — More about relationship in a database

From"Tony Johansson" <johansson.andersson@telia.com>
Date2014-02-16 18:26 +0100
SubjectMore about relationship in a database
Message-ID<ldqsci$ths$1@dont-email.me>
Assume I have a table in the database called Inventory.
Now what is a resonable design type between Inventory and Product.
Where should the foreign key be placed ?

//Tony

[toc] | [next] | [standalone]


#1686

FromErland Sommarskog <esquel@sommarskog.se>
Date2014-02-16 19:42 +0100
Message-ID<XnsA2D6C885F7C41Yazorman@127.0.0.1>
In reply to#1685
Tony Johansson (johansson.andersson@telia.com) writes:
> Assume I have a table in the database called Inventory.
> Now what is a resonable design type between Inventory and Product.
> Where should the foreign key be placed ?

That depends on what's in these tables.

If a given product can be associated with one given invetory at a time, the 
InventoryId would be a foreign-key column in the Products table.

On the other hand, if the Inventory table contains something like the stock 
of all products at all warehouses, the ProductId column would be a foreign-
key column in Inventory.

-- 
Erland Sommarskog, Stockholm, esquel@sommarskog.se

[toc] | [prev] | [standalone]


Back to top | Article view | comp.databases.ms-sqlserver


csiph-web