Skip to content

Commit fc25211

Browse files
committed
add SQL script to create the C.J. Date s+sp+p schema for comparison purposes
1 parent 9c7e74a commit fc25211

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

scripts/cjdate.sql

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
-- creates the cjdate sample database in SQL for comparison with TutorialD
2+
BEGIN;
3+
CREATE TABLE s (
4+
"s#" varchar(2) primary key,
5+
sname varchar(10) NOT NULL,
6+
status int NOT NULL,
7+
city varchar(10) NOT NULL
8+
);
9+
10+
CREATE TABLE p (
11+
"p#" varchar(2) primary key,
12+
pname varchar(10) NOT NULL,
13+
color varchar(10) NOT NULL,
14+
weight real NOT NULL,
15+
city varchar(10) NOT NULL
16+
);
17+
18+
CREATE TABLE sp (
19+
"s#" varchar(2) NOT NULL REFERENCES s("s#"),
20+
"p#" varchar(2) NOT NULL REFERENCES p("p#"),
21+
qty int NOT NULL,
22+
PRIMARY KEY ("s#", "p#")
23+
);
24+
25+
INSERT INTO s(city, "s#", sname, status) VALUES ('Athens','S5','Adams',30),('Paris','S3','Blake',30),('London','S1','Smith',20),('Paris','S2','Jones',10),('London','S4','Clark',20);
26+
27+
INSERT INTO p(city,color,"p#",pname,weight) VALUES ('London','Red','P6','Cog',19),('Oslo','Blue','P3','Screw',17),('London','Red','P4','Screw',14),('London','Red','P1','Nut',12),('Paris','Green','P2','Bolt',17),('Paris','Blue','P5','Cam',12);
28+
29+
INSERT INTO sp("p#",qty,"s#") VALUES ('P1',300,'S2'),('P1',300,'S1'),('P2',400,'S2'),('P2',200,'S4'),('P2',200,'S3'),('P2',200,'S1'),('P3',400,'S1'),('P4',200,'S1'),('P4',300,'S4'),('P5',400,'S4'),('P5',100,'S1'),('P6',100,'S1');
30+
COMMIT;

0 commit comments

Comments
 (0)