1. Now, consider the following instances of the Customer and Reserves tables: (2
ID: 3739543 • Letter: 1
Question
1. Now, consider the following instances of the Customer and Reserves tables: (20 Pts) Customer Reserves CID Name Age City State CID Title Joe 27 Berkeley CA 23 akland CA Albany CA Hary 38 Berkeley CA Sleeper Bananas 2 Sleeper Date 01/01/01 01/01/01 01/01/01 2 Betty 3 Sally 49 A Annie Hal 02/01/01 2 Sleeper Interiors 4 Sleeper 02/01/01 02/01/0 03/01/01 1) Write the DDL code to build the above database. (8 Pts) Please determine the data type for each attribute by yourself. Make sure you can set primary key and foreign key correctly. i. . iii. Create table command onlv.Explanation / Answer
Answer:
Elimination of Datatype
CID in Customer table is Primary key
CID in Reserves table is Foreign Key
CREATE TABLE Customer
(
CID int NOT NULL,
Name varchar(50),
Age int,
City varchar(20),
State varchar(10),
PRIMARY KEY (CID)
); /*This query creates table Customer with CID as Primary key*/
output:
1 Table(s) created
CREATE TABLE Reserves
(
CID int,
Title varchar(30),
Date Date,
FOREIGN KEY (CID)
REFERENCES Customer(CID)
);/*This query creates Reserves table with CID as foreign key*/
output:
1 Table(s) created.
Customer Column Name Data type Size NULL Constraint CID int 4 NO Primary Key Name varchar 50 Yes Age int 4 Yes City varchar 20 Yes State varchar 10 YesRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.