Fix sql script - D025
authorBoris Villazon-Terrazas <bvillazon@fi.upm.es>
Mon, 02 Apr 2012 15:20:35 +0200
changeset 83 2b3ad9b7b007
parent 82 6d6412e76679
child 84 1105058eb3c9
Fix sql script - D025
D025-3tables3primarykeys3foreignkeys/create.sql
ts1.zip
--- a/D025-3tables3primarykeys3foreignkeys/create.sql	Thu Mar 29 20:04:35 2012 +0200
+++ b/D025-3tables3primarykeys3foreignkeys/create.sql	Mon Apr 02 15:20:35 2012 +0200
@@ -41,7 +41,6 @@
               
 CREATE TABLE "Projects" (
 	"lead" INT,
-	-- FOREIGN KEY ("lead") REFERENCES "People"("ID"),
 	"name" VARCHAR(50), 
 	UNIQUE ("lead", "name"), 
 	"deptName" VARCHAR(50), 
@@ -51,15 +50,17 @@
 );
 CREATE TABLE "TaskAssignments" (
 	"worker" INT,
-	-- FOREIGN KEY ("worker") REFERENCES "People"("ID"),
 	"project" VARCHAR(50), 
 	PRIMARY KEY ("worker", "project"), 
 	"deptName" VARCHAR(50), 
 	"deptCity" VARCHAR(50),
-	FOREIGN KEY ("worker") REFERENCES "People"("ID"),
 	FOREIGN KEY ("project", "deptName", "deptCity") REFERENCES "Projects"("name", "deptName", "deptCity"),
 	FOREIGN KEY ("deptName", "deptCity") REFERENCES "Department"("name", "city")
 );
+
+ALTER TABLE "Projects" ADD FOREIGN KEY("lead") REFERENCES "People"("ID");
+ALTER TABLE "TaskAssignments" ADD FOREIGN KEY("worker") REFERENCES "People"("ID");
+
 INSERT INTO  "Projects" ("lead", "name",          "deptName",   "deptCity" )
                  VALUES (8,      'pencil survey', 'accounting', 'Cambridge');
 INSERT INTO  "Projects" ("lead", "name",          "deptName",   "deptCity" )
Binary file ts1.zip has changed