Book : Murach SQL server 2008 Write a script that will create the below tables w
ID: 3540634 • Letter: B
Question
Book : Murach SQL server 2008
Write a script that will create the below tables with the indicated relations.
Your script must build a database that contains the tables specified in the diagram. You need to check to see if the database exists and if it does not create the database, if it does exist then skip this step. For all tables check to see if they exist, if they do delete the table then recreate the table. You can use any name for your database as you like by following the rules for coding object names (pg. 325). You will need to create the tables in the correct order. In your CREATE table statement you need to define primary keys, foreign keys, foreign key constraints to enforce referential integrity, and create indexes for the columns that need to be indexed
Write a script that will create the below tables with the indicated relations. Your script must build a database that contains the tables specified in the diagram. You need to check to see if the database exists and if it does not create the database, if it does exist then skip this step. For all tables check to see if they exist, if they do delete the table then recreate the table. You can use any name for your database as you like by following the rules for coding object names (pg. 325). You will need to create the tables in the correct order. In your CREATE table statement you need to define primary keys, foreign keys, foreign key constraints to enforce referential integrity, and create indexes for the columns that need to be indexedExplanation / Answer
create table CUSTOMERS
(
CustomerID varchar(50) NOT NULL ,
CustomerName varchar(500) NOT NULL ,
CustomerAddress varchar(500) NOT NULL ,
CustomerPhone varchar(50) NOT NULL ,
PRIMARY KEY (CustomerID)
)
create table SHIPPERS
(
ShipperID varchar(50) NOT NULL ,
ShipperName varchar(500) NOT NULL ,
ShipperAddress varchar(500) NOT NULL ,
ShipperPhone varchar(50) NOT NULL ,
PRIMARY KEY (ShipperID)
)
create table Orders
(
OrderID varchar(50) NOT NULL ,
CustomerID varchar(50) NOT NULL ,
EmployeeID varchar(50) NOT NULL ,
OrderDate date() NOT NULL ,
ShipperID varchar(50) NOT NULL ,
ShipAdderss varchar(500) NOT NULL ,
ShipDate date() NOT NULL ,
PRIMARY KEY (OrderID)
)
Hope this helps....