. BSBM DDL
authorEric Prud'hommeaux <eric@w3.org>
Sun, 13 Jun 2010 07:19:19 -0400
changeset 210 f92fc8e0599d
parent 209 0bb89ba4ba18
child 211 433055df332e
. BSBM DDL
src/test/scala/SparqlToSparqlToSqlTest.scala
--- a/src/test/scala/SparqlToSparqlToSqlTest.scala	Sun Jun 13 05:21:51 2010 -0400
+++ b/src/test/scala/SparqlToSparqlToSqlTest.scala	Sun Jun 13 07:19:19 2010 -0400
@@ -334,16 +334,18 @@
 """
   }
 
-  // test("hospital as view") {
-  //   val sparqlParser = Sparql()
-  //   println("hospital view...")
-  //   val view = toView(List(db2hl7), hosp1, StemURI("http://hospital.example/DB/"))
-  //   println("hospital view: " + view)
-//     val sqlParser = Sql()
-//     val expected = sqlParser.parseAll(sqlParser.createview, """
-// """).get
-//     assert(expected === view)
-  // }
+/*
+  test("hospital as view") {
+    val sparqlParser = Sparql()
+    println("hospital view...")
+    val view = toView(List(db2hl7), hosp1, StemURI("http://hospital.example/DB/"))
+    println("hospital view: " + view)
+    val sqlParser = Sql()
+    val expected = sqlParser.parseAll(sqlParser.createview, """
+""").get
+    assert(expected === view)
+  }
+ */
 
   /* ========== BSBM database tests ==========
    *
@@ -356,26 +358,12 @@
   vendor INT,
   price DOUBLE,
   validFrom DATETIME,
-  PRIMARY KEY (nr)
-);
-
-"""
-  val bsbmDb:DatabaseDesc = DDLParser.parseAll(DDLParser.ddl, bsbmDdl).get
-
-  val bsbmDdl_orig = """
-CREATE TABLE offer (
-  nr INT,
-  product INT,
-  producer INT,
-  vendor INT,
-  price DOUBLE,
-  validFrom DATETIME,
   validTo DATETIME,
   deliveryDays INT,
   offerWebpage STRING,
   publisher INT,
   publishDate DATE,
-  PRIMARY KEY (nr),
+  PRIMARY KEY (nr)
 );
 
 
@@ -421,14 +409,14 @@
   propertyTex6 STRING,
   publisher INT,
   publishDate DATE,
-  PRIMARY KEY (nr),
+  PRIMARY KEY (nr)
 );
 
 
 CREATE TABLE productfeature (
   nr INT,
   label STRING,
-  comment SRING,
+  comment STRING,
   publisher INT,
   publishDate DATE,
   PRIMARY KEY (nr)
@@ -438,14 +426,14 @@
 CREATE TABLE productfeatureproduct (
   product INT,
   productFeature INT,
-  PRIMARY KEY (product,productFeature)
+  PRIMARY KEY (productFeature)
 );
 
 
 CREATE TABLE producttype (
   nr INT,
   label STRING,
-  comment varchar(2000),
+  comment STRING,
   parent INT,
   publisher INT,
   publishDate DATE,
@@ -456,7 +444,7 @@
 CREATE TABLE producttypeproduct (
   product INT,
   productType INT,
-  PRIMARY KEY (product,productType)
+  PRIMARY KEY (productType)
 );
 
 
@@ -467,7 +455,7 @@
   person INT,
   reviewDate DATETIME,
   title STRING,
-  text text CHARACTER SET utf8 COLLATE utf8_bin,
+  text STRING,
   language STRING,
   rating1 INT,
   rating2 INT,
@@ -475,9 +463,7 @@
   rating4 INT,
   publisher INT,
   publishDate DATE,
-  PRIMARY KEY (nr),
-  KEY product (product),
-  KEY person (person)
+  PRIMARY KEY (nr)
 );
 
 
@@ -492,6 +478,12 @@
   PRIMARY KEY (nr)
 );
 """
+  /*
+   productfeatureproduct ( PRIMARY KEY (product,productFeature) );
+   producttypeproduct ( PRIMARY KEY (product,productType) );
+   */
+  val bsbmDb:DatabaseDesc = DDLParser.parseAll(DDLParser.ddl, bsbmDdl).get
+
   val delme = Sparql() // re-use ConstructParser ?
   val db2bsbm = delme.parseAll(delme.construct, """
 PREFIX map: <file:/E:/code/d2r-server-0.4/d2r-mapping.n3#>
@@ -553,18 +545,22 @@
 LIMIT 10
 """
     .replaceAll("<http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductFeature([0-9]+)>",
-		"<http://bsbm.example/db/productfeatureproduct.ID.$1#record>")
+		"<http://bsbm.example/db/productfeatureproduct/productFeature.$1#record>")
     .replaceAll("<http://www4.wiwiss.fu-berlin.de/bizer/bsbm/v01/instances/ProductType([0-9]+)>",
-		"<http://bsbm.example/db/producttypeproduct.ID.$1#record>")
+		"<http://bsbm.example/db/producttypeproduct/productType.$1#record>")
 
     val bsbmQuery = sparqlParser.parseAll(sparqlParser.select, queryStr).get
 
     val stemQuery = sparqlParser.parseAll(sparqlParser.select, """
+PREFIX product: <http://bsbm.example/db/product#>
+PREFIX pfp: <http://bsbm.example/db/productfeatureproduct#>
+PREFIX ptp: <http://bsbm.example/db/producttypeproduct#>
+
 SELECT ?product ?label WHERE {
-  ?product <http://bsbm.example/db/product#label> ?label .
-  <http://bsbm.example/db/productfeatureproduct.ID.5#record> <http://bsbm.example/db/productfeatureproduct#product> ?product .
-  <http://bsbm.example/db/producttypeproduct.ID.59#record> <http://bsbm.example/db/producttypeproduct#product> ?product .
-  <http://bsbm.example/db/productfeatureproduct.ID.7#record> <http://bsbm.example/db/productfeatureproduct#product> ?product .
+  ?product                                                   product:label ?label .
+  <http://bsbm.example/db/producttypeproduct/productType.59#record>   ptp:product ?product .
+  <http://bsbm.example/db/productfeatureproduct/productFeature.5#record> pfp:product ?product .
+  <http://bsbm.example/db/productfeatureproduct/productFeature.7#record> pfp:product ?product .
   FILTER (?value1 > 578)
 }
 """).get
@@ -576,7 +572,7 @@
  WHERE R_emp.empid IS NOT NULL AND R_emp.lastName="Smith"
 """).get
     val asStem = SparqlToSparql(bsbmQuery, List(db2bsbm))
-    // assert(asStem === stemQuery)
+    assert(asStem === stemQuery)
     // val (asSql, _) = SparqlToSql(bsbmDb, asStem, StemURI("http://bsbm.example/db/"), false, false)
     // assert(asSql === sqlQuery)
     val output = """