EXERCISE 2.3.1: create table Product ( maker char(255), model number, typex char
ID: 3604869 • Letter: E
Question
EXERCISE 2.3.1:
create table Product (
maker char(255),
model number,
typex char(255)
);
Exercise 2.3.1b
create table PC (
model number,
speed number,
ram number,
hd number,
price number
);
create table Laptop (
Model number,
speed number,
ram number,
hd number,
screen number,
price number
);
create table Printer (
Model number,
color number,
typex char(255)
price number
);
Exercise 7.1.3: Suggest suitable keys and foreign keys for the relations of the PC database Product (maker, mode1, type) PC(model, speed, ram, hd, price) Laptop(model, speed, ram, hd, screen, price) Printer (model, color. type, price) of Exercise 2.4.1. Modify your SQL schema from Exercise 2.3.1 to include declarations of these keysExplanation / Answer
For the given DB,
The product information is given the model number helps to identify different products with different maker and type of products. The types of products include PC, Laptop, Printers.
So the “model” becomes the primary key .
create table Product (
maker char(255),
model number,
typex char(255),
PRIMARY KEY(model)
);
Now the PC table
In PC table for each model number, it has speed , RAM size , hard disk storage and the price.AS these features cannot help in identifying unique PC, only the model number does and this table contains the foreign key (model) which is mapping to the Product table.
Exercise 2.3.1b
create table PC (
model number,
speed number,
ram number,
hd number,
price number,
FOREIGN KEY (model) REFERENCES Product (model)
);
create table Laptop (
Model number,
speed number,
ram number,
hd number,
screen number,
price number,
FOREIGN KEY (model) REFERENCES Product (model)
);
create table Printer (
Model number,
color number,
typex char(255)
price number,
FOREIGN KEY (model) REFERENCES Product (model)
);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.