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


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

Re: A question about relationship

X-Received by 10.66.144.228 with SMTP id sp4mr11807592pab.5.1392131488574; Tue, 11 Feb 2014 07:11:28 -0800 (PST)
X-Received by 10.182.33.4 with SMTP id n4mr266243obi.9.1392131488241; Tue, 11 Feb 2014 07:11:28 -0800 (PST)
Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!uq10no16032252igb.0!news-out.google.com!vg8ni31igb.0!nntp.google.com!uq10no16032237igb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.databases.ms-sqlserver
Date Tue, 11 Feb 2014 07:11:28 -0800 (PST)
In-Reply-To <lddcn4$i2b$1@dont-email.me>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=173.61.139.203; posting-account=SOVadwoAAAB3h7W1MLW9kMYtEc2JW2L8
NNTP-Posting-Host 173.61.139.203
References <ldan3d$f0i$1@dont-email.me> <XnsA2D0F0AEE3E6Yazorman@127.0.0.1> <lddcn4$i2b$1@dont-email.me>
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <cc80175a-413c-46db-92af-2c236f9044d8@googlegroups.com> (permalink)
Subject Re: A question about relationship
From Ross Presser <rpresser@gmail.com>
Injection-Date Tue, 11 Feb 2014 15:11:28 +0000
Content-Type text/plain; charset=ISO-8859-1
Xref csiph.com comp.databases.ms-sqlserver:1672

Show key headers only | View raw


On Tuesday, February 11, 2014 9:39:17 AM UTC-5, Tony Johansson wrote:
> Yes a customer without order sounds ok
> 
> But order without customer is incorrect.

It isn't true. The book is describing the database incorrectly.

The Northwind database can be downloaded here
http://www.microsoft.com/en-us/download/confirmation.aspx?id=23654

And it can be seen from the scripts that each Order must relate 
to one Customer. See the section I have marked out with hyphens:

CREATE TABLE "Orders" (
	"OrderID" "int" IDENTITY (1, 1) NOT NULL ,
	"CustomerID" nchar (5) NULL ,
	"EmployeeID" "int" NULL ,
	"OrderDate" "datetime" NULL ,
	"RequiredDate" "datetime" NULL ,
	"ShippedDate" "datetime" NULL ,
	"ShipVia" "int" NULL ,
	"Freight" "money" NULL CONSTRAINT "DF_Orders_Freight" DEFAULT (0),
	"ShipName" nvarchar (40) NULL ,
	"ShipAddress" nvarchar (60) NULL ,
	"ShipCity" nvarchar (15) NULL ,
	"ShipRegion" nvarchar (15) NULL ,
	"ShipPostalCode" nvarchar (10) NULL ,
	"ShipCountry" nvarchar (15) NULL ,
	CONSTRAINT "PK_Orders" PRIMARY KEY  CLUSTERED 
	(
		"OrderID"
	),
------------------------------------------------------    
	CONSTRAINT "FK_Orders_Customers" FOREIGN KEY 
	(
		"CustomerID"
	) REFERENCES "dbo"."Customers" (
		"CustomerID
	),
------------------------------------------------------    
	CONSTRAINT "FK_Orders_Employees" FOREIGN KEY 
	(
		"EmployeeID"
	) REFERENCES "dbo"."Employees" (
		"EmployeeID"
	),
	CONSTRAINT "FK_Orders_Shippers" FOREIGN KEY 
	(
		"ShipVia"
	) REFERENCES "dbo"."Shippers" (
		"ShipperID"
	)
)

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


Thread

A question about relationship "Tony Johansson" <johansson.andersson@telia.com> - 2014-02-10 15:18 +0100
  Re: A question about relationship Erland Sommarskog <esquel@sommarskog.se> - 2014-02-10 23:39 +0100
    Re: A question about relationship "Tony Johansson" <johansson.andersson@telia.com> - 2014-02-11 15:39 +0100
      Re: A question about relationship Ross Presser <rpresser@gmail.com> - 2014-02-11 07:11 -0800
        Re: A question about relationship bradbury9 <ray.bradbury9@gmail.com> - 2014-02-11 08:43 -0800
          Re: A question about relationship Ross Presser <rpresser@gmail.com> - 2014-02-11 09:33 -0800
        Re: A question about relationship Lennart Jonsson <erik.lennart.jonsson@gmail.com> - 2014-02-11 18:01 +0100
      Re: A question about relationship Erland Sommarskog <esquel@sommarskog.se> - 2014-02-11 21:54 +0100
        Re: A question about relationship rja.carnegie@gmail.com - 2014-02-11 13:49 -0800
          Re: A question about relationship Erland Sommarskog <esquel@sommarskog.se> - 2014-02-11 23:23 +0100

csiph-web