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


Groups > comp.databases.ms-sqlserver > #1686

Re: More about relationship in a database

From Erland Sommarskog <esquel@sommarskog.se>
Newsgroups comp.databases.ms-sqlserver
Subject Re: More about relationship in a database
Date 2014-02-16 19:42 +0100
Organization Erland Sommarskog
Message-ID <XnsA2D6C885F7C41Yazorman@127.0.0.1> (permalink)
References <ldqsci$ths$1@dont-email.me>

Show all headers | View raw


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

Back to comp.databases.ms-sqlserver | Previous | NextPrevious in thread | Find similar


Thread

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

csiph-web