--- a/directmapping/src/test/scala/DirectMappingTest.scala Fri Nov 26 11:26:26 2010 -0500
+++ b/directmapping/src/test/scala/DirectMappingTest.scala Fri Nov 26 12:02:52 2010 -0500
@@ -7,203 +7,9 @@
import org.scalatest.FunSuite
-object SchemasFromDirectMappingSpec {
-
- val SqlParser = sql.SqlParser()
-
- val db_emp_adder = SqlParser.parseAll(SqlParser.ddl, """
-CREATE TABLE Addresses (ID INT PRIMARY KEY, city STRING, state STRING);
-INSERT INTO Addresses (ID, city, state) VALUES (18, "Cambridge", "MA");
-CREATE TABLE People (ID INT PRIMARY KEY, fname STRING, addr INT, FOREIGN KEY (addr) REFERENCES Addresses(ID));
-INSERT INTO People (ID, fname, addr) VALUES (7, "Bob", 18);
-INSERT INTO People (ID, fname, addr) VALUES (8, "Sue", NULL);
-""").get
-
- val directgraph_emp_adder:Graph =
- Set(
- Triple(IRI("People/ID.7#_"),IRI("People#ID"),TypedLiteral("7",IRI("http://www.w3.org/2001/XMLSchema#int"))),
- Triple(IRI("People/ID.7#_"),IRI("People#fname"),TypedLiteral("Bob",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("People/ID.7#_"),IRI("People#addr"),IRI("Addresses/ID.18#_")),
- Triple(IRI("People/ID.8#_"),IRI("People#ID"),TypedLiteral("8",IRI("http://www.w3.org/2001/XMLSchema#int"))),
- Triple(IRI("People/ID.8#_"),IRI("People#fname"),TypedLiteral("Sue",IRI("http://www.w3.org/2001/XMLSchema#string"))),
-
- Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#ID"),TypedLiteral("18",IRI("http://www.w3.org/2001/XMLSchema#int"))),
- Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#city"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#state"),TypedLiteral("MA",IRI("http://www.w3.org/2001/XMLSchema#string")))
- )
-
- val db_multi_key = SqlParser.parseAll(SqlParser.ddl, """
-CREATE TABLE Addresses (ID INT PRIMARY KEY, city STRING, state STRING);
-INSERT INTO Addresses (ID, city, state) VALUES (18, "Cambridge", "MA");
-CREATE TABLE Department (ID INT PRIMARY KEY, name STRING, city STRING,
- manager INT, FOREIGN KEY (manager) REFERENCES People(ID), UNIQUE (name, city));
-INSERT INTO Department (ID, name, city, manager) VALUES (23, "accounting", "Cambridge", 8);
-CREATE TABLE People (ID INT PRIMARY KEY, fname STRING,
- addr INT, FOREIGN KEY (addr) REFERENCES Addresses(ID),
- deptName STRING, deptCity STRING, FOREIGN KEY (deptName, deptCity) REFERENCES Department(name, city));
-INSERT INTO People (ID, fname, addr, deptName, deptCity) VALUES (7, "Bob", 18, "accounting", "Cambridge");
-INSERT INTO People (ID, fname, addr, deptName, deptCity) VALUES (8, "Sue", NULL, NULL, NULL);
-""").get
-
- val directgraph_multi_key:Graph =
- Set(
- Triple(IRI("People/ID.7#_"),IRI("People#deptName"),TypedLiteral("accounting",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("People/ID.7#_"),IRI("People#deptCity"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("People/ID.7#_"),IRI("People#deptName_deptCity"),IRI("Department/ID.23#_")),
-
- Triple(IRI("Department/ID.23#_"),IRI("Department#ID"),TypedLiteral("23",IRI("http://www.w3.org/2001/XMLSchema#int"))),
- Triple(IRI("Department/ID.23#_"),IRI("Department#name"),TypedLiteral("accounting",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("Department/ID.23#_"),IRI("Department#city"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("Department/ID.23#_"),IRI("Department#manager"),IRI("People/ID.8#_")),
-
- Triple(IRI("People/ID.7#_"),IRI("People#ID"),TypedLiteral("7",IRI("http://www.w3.org/2001/XMLSchema#int"))),
- Triple(IRI("People/ID.7#_"),IRI("People#fname"),TypedLiteral("Bob",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("People/ID.7#_"),IRI("People#addr"),IRI("Addresses/ID.18#_")),
- Triple(IRI("People/ID.8#_"),IRI("People#ID"),TypedLiteral("8",IRI("http://www.w3.org/2001/XMLSchema#int"))),
- Triple(IRI("People/ID.8#_"),IRI("People#fname"),TypedLiteral("Sue",IRI("http://www.w3.org/2001/XMLSchema#string"))),
-
- Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#ID"),TypedLiteral("18",IRI("http://www.w3.org/2001/XMLSchema#int"))),
- Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#city"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#state"),TypedLiteral("MA",IRI("http://www.w3.org/2001/XMLSchema#string"))))
-
- val db_ref_no_pk = SqlParser.parseAll(SqlParser.ddl, """
-CREATE TABLE Addresses (ID INT PRIMARY KEY, city STRING, state STRING);
-INSERT INTO Addresses (ID, city, state) VALUES (18, "Cambridge", "MA");
-CREATE TABLE Department (ID INT PRIMARY KEY, name STRING, city STRING, manager INT,
- FOREIGN KEY (manager) REFERENCES People(ID),
- UNIQUE (name, city));
-INSERT INTO Department (ID, name, city, manager) VALUES (23, "accounting", "Cambridge", 8);
-CREATE TABLE People (ID INT PRIMARY KEY, fname STRING, addr INT,
- FOREIGN KEY (addr) REFERENCES Addresses(ID),
- deptName STRING, deptCity STRING,
- FOREIGN KEY (deptName, deptCity) REFERENCES Department(name, city));
-INSERT INTO People (ID, fname, addr, deptName, deptCity) VALUES (7, "Bob", 18, "accounting", "Cambridge");
-INSERT INTO People (ID, fname, addr, deptName, deptCity) VALUES (8, "Sue", NULL, NULL, NULL);
-CREATE TABLE Projects (lead INT,
- FOREIGN KEY (lead) REFERENCES People(ID),
- name STRING, UNIQUE (lead, name),
- deptName STRING, deptCity STRING,
- UNIQUE (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");
-CREATE TABLE TaskAssignments (worker INT,
- FOREIGN KEY (worker) REFERENCES People(ID),
- project STRING, PRIMARY KEY (worker, project),
- deptName STRING, deptCity STRING,
- 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 TaskAssignments (worker, project, deptName, deptCity) VALUES (7, "pencil survey", "accounting", "Cambridge");
-""").get
-
- val directmapping_ref_no_pk =
- Set(
- Triple(BNode("a"), IRI("Projects#lead"), IRI("People/ID.8#_")),
- Triple(BNode("a"), IRI("Projects#name"), TypedLiteral("pencil survey", IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(BNode("a"), IRI("Projects#deptName"), TypedLiteral("accounting", IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(BNode("a"), IRI("Projects#deptCity"), TypedLiteral("Cambridge", IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(BNode("a"), IRI("Projects#deptName_deptCity"), IRI("Department/ID.23#_")),
-
- Triple(BNode("b"), IRI("Projects#lead"), IRI("People/ID.8#_")),
- Triple(BNode("b"), IRI("Projects#name"), TypedLiteral("eraser survey", IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(BNode("b"), IRI("Projects#deptName"), TypedLiteral("accounting", IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(BNode("b"), IRI("Projects#deptCity"), TypedLiteral("Cambridge", IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(BNode("b"), IRI("Projects#deptName_deptCity"), IRI("Department/ID.23#_")),
-
- Triple(IRI("TaskAssignments/worker.7_project.pencil+survey#_"), IRI("TaskAssignments#worker"), IRI("People/ID.7#_")),
- Triple(IRI("TaskAssignments/worker.7_project.pencil+survey#_"), IRI("TaskAssignments#project"), TypedLiteral("pencil survey", IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("TaskAssignments/worker.7_project.pencil+survey#_"), IRI("TaskAssignments#deptName"), TypedLiteral("accounting", IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("TaskAssignments/worker.7_project.pencil+survey#_"), IRI("TaskAssignments#deptCity"), TypedLiteral("Cambridge", IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("TaskAssignments/worker.7_project.pencil+survey#_"), IRI("TaskAssignments#deptName_deptCity"), IRI("Department/ID.23#_")),
- Triple(IRI("TaskAssignments/worker.7_project.pencil+survey#_"), IRI("TaskAssignments#project_deptName_deptCity"), BNode("a")),
-
- Triple(IRI("People/ID.7#_"),IRI("People#deptName"),TypedLiteral("accounting",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("People/ID.7#_"),IRI("People#deptCity"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("People/ID.7#_"),IRI("People#deptName_deptCity"),IRI("Department/ID.23#_")),
-
- Triple(IRI("Department/ID.23#_"),IRI("Department#ID"),TypedLiteral("23",IRI("http://www.w3.org/2001/XMLSchema#int"))),
- Triple(IRI("Department/ID.23#_"),IRI("Department#name"),TypedLiteral("accounting",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("Department/ID.23#_"),IRI("Department#city"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("Department/ID.23#_"),IRI("Department#manager"),IRI("People/ID.8#_")),
-
- Triple(IRI("People/ID.7#_"),IRI("People#ID"),TypedLiteral("7",IRI("http://www.w3.org/2001/XMLSchema#int"))),
- Triple(IRI("People/ID.7#_"),IRI("People#fname"),TypedLiteral("Bob",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("People/ID.7#_"),IRI("People#addr"),IRI("Addresses/ID.18#_")),
- Triple(IRI("People/ID.8#_"),IRI("People#ID"),TypedLiteral("8",IRI("http://www.w3.org/2001/XMLSchema#int"))),
- Triple(IRI("People/ID.8#_"),IRI("People#fname"),TypedLiteral("Sue",IRI("http://www.w3.org/2001/XMLSchema#string"))),
-
- Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#ID"),TypedLiteral("18",IRI("http://www.w3.org/2001/XMLSchema#int"))),
- Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#city"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#state"),TypedLiteral("MA",IRI("http://www.w3.org/2001/XMLSchema#string")))
- )
-
- val db_hier_tabl_proto = SqlParser.parseAll(SqlParser.ddl, """
-CREATE TABLE Addresses (ID INT PRIMARY KEY, city STRING, state STRING);
-INSERT INTO Addresses (ID, city, state) VALUES (18, "Cambridge", "MA");
-CREATE TABLE People (ID INT PRIMARY KEY, fname STRING, addr INT,
- FOREIGN KEY (addr) REFERENCES Addresses(ID));
-INSERT INTO People (ID, fname, addr) VALUES (7, "Bob", 18);
-CREATE TABLE Offices (ID INT PRIMARY KEY,
- building INT, ofcNumber STRING,
- FOREIGN KEY (ID) REFERENCES Addresses(ID));
-INSERT INTO Offices (ID, building, ofcNumber) VALUES (18, 32, "G528");
-""").get
-
- val directmapping_hier_tabl_proto:Graph =
- Set(
- Triple(IRI("Addresses/ID.18#_"),IRI("Offices#ID"),TypedLiteral("18",IRI("http://www.w3.org/2001/XMLSchema#int"))),
- Triple(IRI("Addresses/ID.18#_"),IRI("Offices#building"),TypedLiteral("32",IRI("http://www.w3.org/2001/XMLSchema#int"))),
- Triple(IRI("Addresses/ID.18#_"),IRI("Offices#ofcNumber"),TypedLiteral("G528",IRI("http://www.w3.org/2001/XMLSchema#string"))),
-
- Triple(IRI("People/ID.7#_"),IRI("People#ID"),TypedLiteral("7",IRI("http://www.w3.org/2001/XMLSchema#int"))),
- Triple(IRI("People/ID.7#_"),IRI("People#fname"),TypedLiteral("Bob",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("People/ID.7#_"),IRI("People#addr"),IRI("Addresses/ID.18#_")),
-
- Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#ID"),TypedLiteral("18",IRI("http://www.w3.org/2001/XMLSchema#int"))),
- Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#city"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#state"),TypedLiteral("MA",IRI("http://www.w3.org/2001/XMLSchema#string")))
- )
-
- val db_hier_tabl = SqlParser.parseAll(SqlParser.ddl, """
-CREATE TABLE Addresses (ID INT PRIMARY KEY, city STRING, state STRING);
-INSERT INTO Addresses (ID, city, state) VALUES (18, "Cambridge", "MA");
-CREATE TABLE People (ID INT PRIMARY KEY, fname STRING, addr INT,
- FOREIGN KEY (addr) REFERENCES Addresses(ID));
-INSERT INTO People (ID, fname, addr) VALUES (7, "Bob", 18);
-CREATE TABLE Offices (ID INT PRIMARY KEY,
- building INT, ofcNumber STRING,
- FOREIGN KEY (ID) REFERENCES Addresses(ID));
-INSERT INTO Offices (ID, building, ofcNumber) VALUES (18, 32, "G528");
-CREATE TABLE ExecutiveOffices (ID INT PRIMARY KEY,
- desk STRING,
- FOREIGN KEY (ID) REFERENCES Offices(ID));
-INSERT INTO ExecutiveOffices (ID, desk) VALUES (18, "oak");
-""").get
-
- val directgraph_hier_tabl:Graph =
- Set(
- Triple(IRI("Addresses/ID.18#_"),IRI("ExecutiveOffices#ID"),TypedLiteral("18",IRI("http://www.w3.org/2001/XMLSchema#int"))),
- Triple(IRI("Addresses/ID.18#_"),IRI("ExecutiveOffices#desk"),TypedLiteral("oak",IRI("http://www.w3.org/2001/XMLSchema#string"))),
-
- Triple(IRI("Addresses/ID.18#_"),IRI("Offices#ID"),TypedLiteral("18",IRI("http://www.w3.org/2001/XMLSchema#int"))),
- Triple(IRI("Addresses/ID.18#_"),IRI("Offices#building"),TypedLiteral("32",IRI("http://www.w3.org/2001/XMLSchema#int"))),
- Triple(IRI("Addresses/ID.18#_"),IRI("Offices#ofcNumber"),TypedLiteral("G528",IRI("http://www.w3.org/2001/XMLSchema#string"))),
-
- Triple(IRI("People/ID.7#_"),IRI("People#ID"),TypedLiteral("7",IRI("http://www.w3.org/2001/XMLSchema#int"))),
- Triple(IRI("People/ID.7#_"),IRI("People#fname"),TypedLiteral("Bob",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("People/ID.7#_"),IRI("People#addr"),IRI("Addresses/ID.18#_")),
-
- Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#ID"),TypedLiteral("18",IRI("http://www.w3.org/2001/XMLSchema#int"))),
- Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#city"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
- Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#state"),TypedLiteral("MA",IRI("http://www.w3.org/2001/XMLSchema#string")))
- )
-
-}
-
class Test extends FunSuite {
- import SchemasFromDirectMappingSpec._
+ import DirectMappingSpec._
implicit def l2db (rs:List[Relation]):Map[RelName, Relation] =
rs.map(r => (r.name -> r)).toMap
--- a/project/build/RDB2RDF.scala Fri Nov 26 11:26:26 2010 -0500
+++ b/project/build/RDB2RDF.scala Fri Nov 26 12:02:52 2010 -0500
@@ -15,7 +15,8 @@
lazy val rdb = project("rdb", "rdb", new RDB(_))
lazy val sql = project("sql", "sql", new SQL(_), rdb)
lazy val rdf = project("rdf", "rdf", new RDF(_))
- lazy val directmapping = project("directmapping", "directmapping", new DirectMapping(_), rdb, rdf, sql)
+ lazy val sharedtestdata = project("sharedtestdata", "sharedtestdata", new SharedTestData(_), rdb, rdf, sql)
+ lazy val directmapping = project("directmapping", "directmapping", new DirectMapping(_), rdb, rdf, sql, sharedtestdata)
lazy val sparql = project("sparql", "sparql", new SPARQL(_), rdf)
lazy val sparql2sql = project("sparql2sql", "sparql2sql", new SPARQL2SQL(_), sparql, sql)
lazy val sparql2sparql = project("sparql2sparql", "sparql2sparql", new SPARQL2SPARQL(_), sparql)
@@ -29,6 +30,8 @@
class RDF(info: ProjectInfo) extends DefaultProject(info) with Common
+ class SharedTestData(info: ProjectInfo) extends DefaultProject(info) with Common
+
class DirectMapping(info: ProjectInfo) extends DefaultProject(info) with Common
class SPARQL(info: ProjectInfo) extends DefaultProject(info) with Common
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sharedtestdata/src/main/scala/DirectMappingSpec.scala Fri Nov 26 12:02:52 2010 -0500
@@ -0,0 +1,199 @@
+package org.w3.sw.directmapping
+
+import org.w3.sw.rdf._
+import org.w3.sw.rdb.RDB._
+import org.w3.sw.sql
+
+object DirectMappingSpec {
+
+ val SqlParser = sql.SqlParser()
+
+ val db_emp_adder = SqlParser.parseAll(SqlParser.ddl, """
+CREATE TABLE Addresses (ID INT PRIMARY KEY, city STRING, state STRING);
+INSERT INTO Addresses (ID, city, state) VALUES (18, "Cambridge", "MA");
+CREATE TABLE People (ID INT PRIMARY KEY, fname STRING, addr INT, FOREIGN KEY (addr) REFERENCES Addresses(ID));
+INSERT INTO People (ID, fname, addr) VALUES (7, "Bob", 18);
+INSERT INTO People (ID, fname, addr) VALUES (8, "Sue", NULL);
+""").get
+
+ val directgraph_emp_adder:Graph =
+ Set(
+ Triple(IRI("People/ID.7#_"),IRI("People#ID"),TypedLiteral("7",IRI("http://www.w3.org/2001/XMLSchema#int"))),
+ Triple(IRI("People/ID.7#_"),IRI("People#fname"),TypedLiteral("Bob",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("People/ID.7#_"),IRI("People#addr"),IRI("Addresses/ID.18#_")),
+ Triple(IRI("People/ID.8#_"),IRI("People#ID"),TypedLiteral("8",IRI("http://www.w3.org/2001/XMLSchema#int"))),
+ Triple(IRI("People/ID.8#_"),IRI("People#fname"),TypedLiteral("Sue",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+
+ Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#ID"),TypedLiteral("18",IRI("http://www.w3.org/2001/XMLSchema#int"))),
+ Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#city"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#state"),TypedLiteral("MA",IRI("http://www.w3.org/2001/XMLSchema#string")))
+ )
+
+ val db_multi_key = SqlParser.parseAll(SqlParser.ddl, """
+CREATE TABLE Addresses (ID INT PRIMARY KEY, city STRING, state STRING);
+INSERT INTO Addresses (ID, city, state) VALUES (18, "Cambridge", "MA");
+CREATE TABLE Department (ID INT PRIMARY KEY, name STRING, city STRING,
+ manager INT, FOREIGN KEY (manager) REFERENCES People(ID), UNIQUE (name, city));
+INSERT INTO Department (ID, name, city, manager) VALUES (23, "accounting", "Cambridge", 8);
+CREATE TABLE People (ID INT PRIMARY KEY, fname STRING,
+ addr INT, FOREIGN KEY (addr) REFERENCES Addresses(ID),
+ deptName STRING, deptCity STRING, FOREIGN KEY (deptName, deptCity) REFERENCES Department(name, city));
+INSERT INTO People (ID, fname, addr, deptName, deptCity) VALUES (7, "Bob", 18, "accounting", "Cambridge");
+INSERT INTO People (ID, fname, addr, deptName, deptCity) VALUES (8, "Sue", NULL, NULL, NULL);
+""").get
+
+ val directgraph_multi_key:Graph =
+ Set(
+ Triple(IRI("People/ID.7#_"),IRI("People#deptName"),TypedLiteral("accounting",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("People/ID.7#_"),IRI("People#deptCity"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("People/ID.7#_"),IRI("People#deptName_deptCity"),IRI("Department/ID.23#_")),
+
+ Triple(IRI("Department/ID.23#_"),IRI("Department#ID"),TypedLiteral("23",IRI("http://www.w3.org/2001/XMLSchema#int"))),
+ Triple(IRI("Department/ID.23#_"),IRI("Department#name"),TypedLiteral("accounting",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("Department/ID.23#_"),IRI("Department#city"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("Department/ID.23#_"),IRI("Department#manager"),IRI("People/ID.8#_")),
+
+ Triple(IRI("People/ID.7#_"),IRI("People#ID"),TypedLiteral("7",IRI("http://www.w3.org/2001/XMLSchema#int"))),
+ Triple(IRI("People/ID.7#_"),IRI("People#fname"),TypedLiteral("Bob",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("People/ID.7#_"),IRI("People#addr"),IRI("Addresses/ID.18#_")),
+ Triple(IRI("People/ID.8#_"),IRI("People#ID"),TypedLiteral("8",IRI("http://www.w3.org/2001/XMLSchema#int"))),
+ Triple(IRI("People/ID.8#_"),IRI("People#fname"),TypedLiteral("Sue",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+
+ Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#ID"),TypedLiteral("18",IRI("http://www.w3.org/2001/XMLSchema#int"))),
+ Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#city"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#state"),TypedLiteral("MA",IRI("http://www.w3.org/2001/XMLSchema#string"))))
+
+ val db_ref_no_pk = SqlParser.parseAll(SqlParser.ddl, """
+CREATE TABLE Addresses (ID INT PRIMARY KEY, city STRING, state STRING);
+INSERT INTO Addresses (ID, city, state) VALUES (18, "Cambridge", "MA");
+CREATE TABLE Department (ID INT PRIMARY KEY, name STRING, city STRING, manager INT,
+ FOREIGN KEY (manager) REFERENCES People(ID),
+ UNIQUE (name, city));
+INSERT INTO Department (ID, name, city, manager) VALUES (23, "accounting", "Cambridge", 8);
+CREATE TABLE People (ID INT PRIMARY KEY, fname STRING, addr INT,
+ FOREIGN KEY (addr) REFERENCES Addresses(ID),
+ deptName STRING, deptCity STRING,
+ FOREIGN KEY (deptName, deptCity) REFERENCES Department(name, city));
+INSERT INTO People (ID, fname, addr, deptName, deptCity) VALUES (7, "Bob", 18, "accounting", "Cambridge");
+INSERT INTO People (ID, fname, addr, deptName, deptCity) VALUES (8, "Sue", NULL, NULL, NULL);
+CREATE TABLE Projects (lead INT,
+ FOREIGN KEY (lead) REFERENCES People(ID),
+ name STRING, UNIQUE (lead, name),
+ deptName STRING, deptCity STRING,
+ UNIQUE (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");
+CREATE TABLE TaskAssignments (worker INT,
+ FOREIGN KEY (worker) REFERENCES People(ID),
+ project STRING, PRIMARY KEY (worker, project),
+ deptName STRING, deptCity STRING,
+ 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 TaskAssignments (worker, project, deptName, deptCity) VALUES (7, "pencil survey", "accounting", "Cambridge");
+""").get
+
+ val directmapping_ref_no_pk =
+ Set(
+ Triple(BNode("a"), IRI("Projects#lead"), IRI("People/ID.8#_")),
+ Triple(BNode("a"), IRI("Projects#name"), TypedLiteral("pencil survey", IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(BNode("a"), IRI("Projects#deptName"), TypedLiteral("accounting", IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(BNode("a"), IRI("Projects#deptCity"), TypedLiteral("Cambridge", IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(BNode("a"), IRI("Projects#deptName_deptCity"), IRI("Department/ID.23#_")),
+
+ Triple(BNode("b"), IRI("Projects#lead"), IRI("People/ID.8#_")),
+ Triple(BNode("b"), IRI("Projects#name"), TypedLiteral("eraser survey", IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(BNode("b"), IRI("Projects#deptName"), TypedLiteral("accounting", IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(BNode("b"), IRI("Projects#deptCity"), TypedLiteral("Cambridge", IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(BNode("b"), IRI("Projects#deptName_deptCity"), IRI("Department/ID.23#_")),
+
+ Triple(IRI("TaskAssignments/worker.7_project.pencil+survey#_"), IRI("TaskAssignments#worker"), IRI("People/ID.7#_")),
+ Triple(IRI("TaskAssignments/worker.7_project.pencil+survey#_"), IRI("TaskAssignments#project"), TypedLiteral("pencil survey", IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("TaskAssignments/worker.7_project.pencil+survey#_"), IRI("TaskAssignments#deptName"), TypedLiteral("accounting", IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("TaskAssignments/worker.7_project.pencil+survey#_"), IRI("TaskAssignments#deptCity"), TypedLiteral("Cambridge", IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("TaskAssignments/worker.7_project.pencil+survey#_"), IRI("TaskAssignments#deptName_deptCity"), IRI("Department/ID.23#_")),
+ Triple(IRI("TaskAssignments/worker.7_project.pencil+survey#_"), IRI("TaskAssignments#project_deptName_deptCity"), BNode("a")),
+
+ Triple(IRI("People/ID.7#_"),IRI("People#deptName"),TypedLiteral("accounting",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("People/ID.7#_"),IRI("People#deptCity"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("People/ID.7#_"),IRI("People#deptName_deptCity"),IRI("Department/ID.23#_")),
+
+ Triple(IRI("Department/ID.23#_"),IRI("Department#ID"),TypedLiteral("23",IRI("http://www.w3.org/2001/XMLSchema#int"))),
+ Triple(IRI("Department/ID.23#_"),IRI("Department#name"),TypedLiteral("accounting",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("Department/ID.23#_"),IRI("Department#city"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("Department/ID.23#_"),IRI("Department#manager"),IRI("People/ID.8#_")),
+
+ Triple(IRI("People/ID.7#_"),IRI("People#ID"),TypedLiteral("7",IRI("http://www.w3.org/2001/XMLSchema#int"))),
+ Triple(IRI("People/ID.7#_"),IRI("People#fname"),TypedLiteral("Bob",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("People/ID.7#_"),IRI("People#addr"),IRI("Addresses/ID.18#_")),
+ Triple(IRI("People/ID.8#_"),IRI("People#ID"),TypedLiteral("8",IRI("http://www.w3.org/2001/XMLSchema#int"))),
+ Triple(IRI("People/ID.8#_"),IRI("People#fname"),TypedLiteral("Sue",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+
+ Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#ID"),TypedLiteral("18",IRI("http://www.w3.org/2001/XMLSchema#int"))),
+ Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#city"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#state"),TypedLiteral("MA",IRI("http://www.w3.org/2001/XMLSchema#string")))
+ )
+
+ val db_hier_tabl_proto = SqlParser.parseAll(SqlParser.ddl, """
+CREATE TABLE Addresses (ID INT PRIMARY KEY, city STRING, state STRING);
+INSERT INTO Addresses (ID, city, state) VALUES (18, "Cambridge", "MA");
+CREATE TABLE People (ID INT PRIMARY KEY, fname STRING, addr INT,
+ FOREIGN KEY (addr) REFERENCES Addresses(ID));
+INSERT INTO People (ID, fname, addr) VALUES (7, "Bob", 18);
+CREATE TABLE Offices (ID INT PRIMARY KEY,
+ building INT, ofcNumber STRING,
+ FOREIGN KEY (ID) REFERENCES Addresses(ID));
+INSERT INTO Offices (ID, building, ofcNumber) VALUES (18, 32, "G528");
+""").get
+
+ val directmapping_hier_tabl_proto:Graph =
+ Set(
+ Triple(IRI("Addresses/ID.18#_"),IRI("Offices#ID"),TypedLiteral("18",IRI("http://www.w3.org/2001/XMLSchema#int"))),
+ Triple(IRI("Addresses/ID.18#_"),IRI("Offices#building"),TypedLiteral("32",IRI("http://www.w3.org/2001/XMLSchema#int"))),
+ Triple(IRI("Addresses/ID.18#_"),IRI("Offices#ofcNumber"),TypedLiteral("G528",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+
+ Triple(IRI("People/ID.7#_"),IRI("People#ID"),TypedLiteral("7",IRI("http://www.w3.org/2001/XMLSchema#int"))),
+ Triple(IRI("People/ID.7#_"),IRI("People#fname"),TypedLiteral("Bob",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("People/ID.7#_"),IRI("People#addr"),IRI("Addresses/ID.18#_")),
+
+ Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#ID"),TypedLiteral("18",IRI("http://www.w3.org/2001/XMLSchema#int"))),
+ Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#city"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#state"),TypedLiteral("MA",IRI("http://www.w3.org/2001/XMLSchema#string")))
+ )
+
+ val db_hier_tabl = SqlParser.parseAll(SqlParser.ddl, """
+CREATE TABLE Addresses (ID INT PRIMARY KEY, city STRING, state STRING);
+INSERT INTO Addresses (ID, city, state) VALUES (18, "Cambridge", "MA");
+CREATE TABLE People (ID INT PRIMARY KEY, fname STRING, addr INT,
+ FOREIGN KEY (addr) REFERENCES Addresses(ID));
+INSERT INTO People (ID, fname, addr) VALUES (7, "Bob", 18);
+CREATE TABLE Offices (ID INT PRIMARY KEY,
+ building INT, ofcNumber STRING,
+ FOREIGN KEY (ID) REFERENCES Addresses(ID));
+INSERT INTO Offices (ID, building, ofcNumber) VALUES (18, 32, "G528");
+CREATE TABLE ExecutiveOffices (ID INT PRIMARY KEY,
+ desk STRING,
+ FOREIGN KEY (ID) REFERENCES Offices(ID));
+INSERT INTO ExecutiveOffices (ID, desk) VALUES (18, "oak");
+""").get
+
+ val directgraph_hier_tabl:Graph =
+ Set(
+ Triple(IRI("Addresses/ID.18#_"),IRI("ExecutiveOffices#ID"),TypedLiteral("18",IRI("http://www.w3.org/2001/XMLSchema#int"))),
+ Triple(IRI("Addresses/ID.18#_"),IRI("ExecutiveOffices#desk"),TypedLiteral("oak",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+
+ Triple(IRI("Addresses/ID.18#_"),IRI("Offices#ID"),TypedLiteral("18",IRI("http://www.w3.org/2001/XMLSchema#int"))),
+ Triple(IRI("Addresses/ID.18#_"),IRI("Offices#building"),TypedLiteral("32",IRI("http://www.w3.org/2001/XMLSchema#int"))),
+ Triple(IRI("Addresses/ID.18#_"),IRI("Offices#ofcNumber"),TypedLiteral("G528",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+
+ Triple(IRI("People/ID.7#_"),IRI("People#ID"),TypedLiteral("7",IRI("http://www.w3.org/2001/XMLSchema#int"))),
+ Triple(IRI("People/ID.7#_"),IRI("People#fname"),TypedLiteral("Bob",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("People/ID.7#_"),IRI("People#addr"),IRI("Addresses/ID.18#_")),
+
+ Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#ID"),TypedLiteral("18",IRI("http://www.w3.org/2001/XMLSchema#int"))),
+ Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#city"),TypedLiteral("Cambridge",IRI("http://www.w3.org/2001/XMLSchema#string"))),
+ Triple(IRI("Addresses/ID.18#_"),IRI("Addresses#state"),TypedLiteral("MA",IRI("http://www.w3.org/2001/XMLSchema#string")))
+ )
+
+}