Course Hero Logo

Unit 8 Discu (4).docx - I downloaded and installed...

Course Hero uses AI to attempt to automatically extract content from documents to surface to you and others so you can study better, e.g., in search results, to enrich docs, and more. This preview shows page 1 - 3 out of 7 pages.

I downloaded and installed Microsoft SQL to be able to use the script rather than usingthe usual mysql workbench as there wasn’t a readymade script for it. It was challengingto set up Microsoft SQL but with help of some Youtube videos I succeeded.I then followed the instructions from the text book and modified the script as it showedin the textbook however I encountered some errors while updating references usingbelow part of the code.[OrderID] int NOT NULL,[CustomerID]nvarchar(5) NOT NULL,[EmployeeID]int NULL,[ShipName]nvarchar(40) NULL,[ShipAddress]nvarchar(60) NULL,[ShipCity]nvarchar(15) NULL,[ShipRegion]nvarchar(15) NULL,[ShipPostalCode]nvarchar(10) NULL,[ShipCountry]nvarchar(15) NULL,[ShipVia]int NULL,[OrderDate]smalldatetime NULL,[RequiredDate]smalldatetime NULL,[ShippedDate]smalldatetime NULL,[Freight]
money NULL,Primary Key (OrderID),Foreign Key (CustomerID) References tblCustomers,Foreign Key (ShipVia) ReferencestblShippers,Constraint valid_ShipDate CHECK (ShippedDate>OrderDate))I got an error message without yet running the code saying “foreign key referenceswrong table”. Hence I tried a reference as below:Foreign Key (ShipVia) References Orders.tblShippers,This still gave me an error. So I went on stackoverflow.com and checked how areference can be added in Microsoft SQL. The solution is to declare the primary key inthe same line as the attribute declaration then the foreign key at the bottom as below:

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 7 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Fall
Professor
Staff
Tags
Foreign key, nvarchar

Newly uploaded documents

Show More

Newly uploaded documents

Show More

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture