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


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

Re: A question about relationship

Newsgroups comp.databases.ms-sqlserver
Date 2014-02-11 07:11 -0800
References <ldan3d$f0i$1@dont-email.me> <XnsA2D0F0AEE3E6Yazorman@127.0.0.1> <lddcn4$i2b$1@dont-email.me>
Message-ID <cc80175a-413c-46db-92af-2c236f9044d8@googlegroups.com> (permalink)
Subject Re: A question about relationship
From Ross Presser <rpresser@gmail.com>

Show all headers | 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