author | Boris Villazon-Terrazas <bvillazon@fi.upm.es> |
Thu, 29 Mar 2012 20:04:35 +0200 | |
changeset 82 | 6d6412e76679 |
parent 81 | 67f385527fb3 |
child 83 | 2b3ad9b7b007 |
D014-3tables1primarykey1foreignkey/mappedc.nq | ||
D014-3tables1primarykey1foreignkey/r2rmlb.ttl | ||
D025-3tables3primarykeys3foreignkeys/create.sql | ||
ts1.zip |
--- a/D014-3tables1primarykey1foreignkey/mappedc.nq Thu Mar 29 11:27:08 2012 +0200 +++ b/D014-3tables1primarykey1foreignkey/mappedc.nq Thu Mar 29 20:04:35 2012 +0200 @@ -3,10 +3,9 @@ <http://example.com/emp/7369> <http://example.com/emp#emptype> <http://example.com/emp/etype/PART_TIME> . <http://example.com/emp/7369> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/emp/etype/PART_TIME> . <http://example.com/emp/7369> <http://example.com/emp#empno> "7369"^^<http://www.w3.org/2001/XMLSchema#integer> . -<http://example.com/emp/7369> <http://example.com/emp#name> "SMITH" . <http://example.com/emp/7369> <http://example.com/emp#job> "CLERK" . -<http://example.com/emp/7369> <http://example.com/emp#deptNum> "10"^^<http://www.w3.org/2001/XMLSchema#integer> . -<http://example.com/emp/7369> <http://example.com/emp#etype> "PART TIME" . +<http://example.com/emp/7369> <http://example.com/emp#deptNum> "10"^^<http://www.w3.org/2001/XMLSchema#positiveInteger> . +<http://example.com/emp/7369> <http://example.com/emp#etype> "PART_TIME" . <http://example.com/emp/7369> <http://example.com/emp#c_ref_deptno> _:Department10 . <http://example.com/emp/7369> <http://example.com/emp#name> "SMITH" . _:Department10 <http://example.com/dept#deptno> "10"^^<http://www.w3.org/2001/XMLSchema#integer> .
--- a/D014-3tables1primarykey1foreignkey/r2rmlb.ttl Thu Mar 29 11:27:08 2012 +0200 +++ b/D014-3tables1primarykey1foreignkey/r2rmlb.ttl Thu Mar 29 20:04:35 2012 +0200 @@ -66,25 +66,25 @@ rr:predicateObjectMap [ rr:predicate emp:jobtype ; - rr:objectMap [ rr:column "jobTypeURI" rr:termType rr:IRI; ] + rr:objectMap [ rr:column "jobTypeURI"; rr:termType rr:IRI; ] ]; rr:predicateObjectMap [ rr:predicate rdf:type ; - rr:objectMap [ rr:column "jobTypeURI" rr:termType rr:IRI; ] + rr:objectMap [ rr:column "jobTypeURI"; rr:termType rr:IRI; ] ]; rr:predicateObjectMap [ rr:predicate emp:emptype ; - rr:objectMap [ rr:column "empTypeURI" rr:termType rr:IRI; ] + rr:objectMap [ rr:column "empTypeURI"; rr:termType rr:IRI; ] ]; rr:predicateObjectMap [ rr:predicate rdf:type ; - rr:objectMap [ rr:column "empTypeURI" rr:termType rr:IRI; ] + rr:objectMap [ rr:column "empTypeURI"; rr:termType rr:IRI; ] ]; rr:predicateObjectMap
--- a/D025-3tables3primarykeys3foreignkeys/create.sql Thu Mar 29 11:27:08 2012 +0200 +++ b/D025-3tables3primarykeys3foreignkeys/create.sql Thu Mar 29 20:04:35 2012 +0200 @@ -25,4 +25,44 @@ ); ALTER TABLE "Department" ADD FOREIGN KEY("manager") REFERENCES "People"("ID"); -ALTER TABLE "People" ADD FOREIGN KEY("deptName", "deptCity") REFERENCES "Department"("name", "city"); \ No newline at end of file +ALTER TABLE "People" ADD FOREIGN KEY("deptName", "deptCity") REFERENCES "Department"("name", "city"); + +INSERT INTO "Addresses" ("ID", "city", "state") + VALUES (18, 'Cambridge', 'MA'); + +INSERT INTO "People" ("ID", "fname", "addr", "deptName", "deptCity" ) + VALUES (8, 'Sue', NULL, NULL, NULL); + +INSERT INTO "Department" ("ID", "name", "city", "manager") + VALUES (23, 'accounting', 'Cambridge', 8); + +INSERT INTO "People" ("ID", "fname", "addr", "deptName", "deptCity" ) + VALUES (7, 'Bob', 18, 'accounting', 'Cambridge'); + +CREATE TABLE "Projects" ( + "lead" INT, + -- FOREIGN KEY ("lead") REFERENCES "People"("ID"), + "name" VARCHAR(50), + UNIQUE ("lead", "name"), + "deptName" VARCHAR(50), + "deptCity" VARCHAR(50), + UNIQUE ("name", "deptName", "deptCity"), + FOREIGN KEY ("deptName", "deptCity") REFERENCES "Department"("name", "city") +); +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") +); +INSERT INTO "Projects" ("lead", "name", "deptName", "deptCity" ) + VALUES (8, 'pencil survey', 'accounting', 'Cambridge'); +INSERT INTO "Projects" ("lead", "name", "deptName", "deptCity" ) + VALUES (8, 'eraser survey', 'accounting', 'Cambridge'); +INSERT INTO "TaskAssignments" ("worker", "project", "deptName", "deptCity" ) + VALUES (7, 'pencil survey', 'accounting', 'Cambridge'); \ No newline at end of file