-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomputer_firm_schema.sql
More file actions
36 lines (33 loc) · 987 Bytes
/
computer_firm_schema.sql
File metadata and controls
36 lines (33 loc) · 987 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
CREATE TABLE product (
maker VARCHAR(10) NOT NULL,
model VARCHAR(50) NOT NULL PRIMARY KEY,
type VARCHAR(50) NOT NULL
);
CREATE TABLE pc (
code INT NOT NULL PRIMARY KEY,
model VARCHAR(50) NOT NULL,
speed SMALLINT NOT NULL,
ram SMALLINT NOT NULL,
hd REAL NOT NULL,
cd VARCHAR(10) NOT NULL,
price DECIMAL(8,4),
CONSTRAINT FK_pc_product FOREIGN KEY (model) REFERENCES product(model)
);
CREATE TABLE laptop (
code INT NOT NULL PRIMARY KEY,
model VARCHAR(50) NOT NULL,
speed SMALLINT NOT NULL,
ram SMALLINT NOT NULL,
hd REAL NOT NULL,
price DECIMAL(8,4),
screen TINYINT NOT NULL,
CONSTRAINT FK_laptop_product FOREIGN KEY (model) REFERENCES product(model)
);
CREATE TABLE printer (
code INT NOT NULL PRIMARY KEY,
model VARCHAR(50) NOT NULL,
color CHAR(1) NOT NULL,
type VARCHAR(10) NOT NULL,
price DECIMAL(8,4),
CONSTRAINT FK_printer_product FOREIGN KEY (model) REFERENCES product(model)
);