SQL Databases are a Moving Target
-
Upload
bernadine-wolf -
Category
Documents
-
view
41 -
download
6
description
Transcript of SQL Databases are a Moving Target
SQL Databases are a Moving SQL Databases are a Moving TargetTarget
Juan F. Sequeda – Juan F. Sequeda – [email protected]@cs.utexas.edu
Syed Hamid Tirmizi – Syed Hamid Tirmizi – [email protected]@cs.utexas.edu
Daniel P. Miranker – Daniel P. Miranker – [email protected]@cs.utexas.edu
Department of Computer SciencesDepartment of Computer Sciences
The University of Texas at AustinThe University of Texas at Austin
3
The Semantic Web VisionThe Semantic Web Vision
DB
Localontology
DB
Localontology
DB
Localontology
Semantic Query Engine
User Layer: Users and agents interact with this layer and query the ontologies
Ontology Layer: defines the semantic representation of RDB. Inference
Database Layer: Data that needs to accessed semantically
4
So what should be done?So what should be done?
• Make it easy for existing databases to generate Semantic Web content.
Research Problem(s):
Generate Ontologies from Database Content• (many systems already make RDF from database
data)• Mapping database restrictions to OWL
– People don’t live past 120 years old• Mining database content for additional domain
knowledge– Professors earn more than teaching assistants
5
Finally: Can the Semantic Web Work?Finally: Can the Semantic Web Work?
DB
Localontology
DB
Localontology
DB
Localontology
Semantic Query Engine
• We see a big problem:– Who builds this?– Who generates
thesemappings?
6
The Semantic Web VisionThe Semantic Web Vision
Localontology
TableContent
DBSchema/Metadata
generate
translate
SQL-query
RDF
Semantic WebQuery Engines
7
Our PositionOur Position
•SQL has semantics– SQL has been evolving it is a moving
target!– SQL DDL can be used to generate local
ontologies– A Greatest Common Denominator like
OWL-DL can aid with data integration
8
Why are SQL Databases Moving Why are SQL Databases Moving Targets?Targets?• In the beginning we had… Relational
ModelStudent(Juan, 22)
• SQL86-89 came out with Table DefinitionsCREATE TABLE employee (
name VARCHAR(100), age INTEGER)
• SQL92 added data integrity ConstraintsCHECK, PRIMARY KEY, FOREIGN KEY, UNIQUE
• SQL99 added Triggers
9
SQL DDL to OntologiesSQL DDL to Ontologies
• Requirements– To create the ontology automatically, we need
to compare the technologies– We need to identify constructs with similar
semantics
• Analysis– Our analysis leads to a layer cake for SQL with
corresponding layers in the Semantic Web stack
• Implementation – We express our transformations as FOL and
use SQL BNF as a guideline for completeness.
10
Relational Model to RDFRelational Model to RDF
• Relational Model– Employee(name, age)– T1: Employee (Juan, 21)
• RDF<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-
syntax-ns#"xmlns:ex="http://www.example.com/#">
<rdf:Description rdf:about="http://www.example.com/employee">
<ex:name>Juan</ex:name><ex:age>21</ex:age>
</rdf:Description></rdf:RDF>
11
Table Definition to RDFSTable Definition to RDFS
• Table DefinitionCREATE TABLE employee (
name VARCHAR(100), age INTEGER)
• RDFS
12
Table Definition to RDFSTable Definition to RDFS<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<rdfs:Class rdf:ID="employee"><rdfs:comment>Employee</rdfs:comment><rdfs:subClassOf
rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax- ns#Resource"/></rdfs:Class>
<rdf:Property rdf:ID="name"><rdfs:comment>Name of Employee</rdfs:comment><rdfs:domain rdf:resource="#employee"/><rdfs:range rdf:resource="http://www.w3.org/1999/02/22-rdf-
syntax-ns#Literal"/></rdf:Property>
<rdf:Property rdf:ID="age"><rdfs:comment>Age of Employee</rdfs:comment><rdfs:domain rdf:resource="#employee"/><rdfs:range rdf:resource="http://www.w3.org/1999/02/22-rdf-
syntax-ns#Literal"/></rdf:Property>
</rdf:RDF>
Table Name
Attributes
Data type
13
SQL to RDFSSQL to RDFS
• Tables rdfs:Class• Columns rdf:Property
– Table rdfs:Domain– Datatype rdfs:Range
• Foreign Keys rdf:Property – Table rdfs:Domain– Referencing Table rdfs:Range
14
SQL to RDFSSQL to RDFS
SQL BNF Shared Semantics
rdfs:Class<table definition> ::= CREATE [ <table scope> ] TABLE <table name> <table contents source> [ … ]
Tables are equivalent to
classes
rdf:Propertyrdfs:domainrdfs:range
<column definition> ::= <column name> <data type> [NOT NULL] [...]
Attributes become
properties having the
domain as the current table
and the range as the datatype.
rdf:Propertyrdfs:domainrdfs:range
<referential constraint definition>::= FOREIGN KEY <left paren> <referencing columns> <right paren> REFERENCES <referenced table and columns> [...]
Foreign Keys are relationships
15
SQL to OWLSQL to OWL
CREATE TABLE employee(employee_id INTEGER PRIMARY KEY,employee_ssn VARCHAR(11) UNIQUE,employee_name VARCHAR(100) NOT NULL,employee_salary INTEGER NOT NULL,employee_type CHAR(8) CHECK ( employee_type IN
('TEMP', 'FULLTIME', 'CONTRACT'))dept INTEGER FOREIGN KEY (dept) REFERENCES
department (dept_id))
CREATE TABLE department(dept_id INTEGER PRIMARY KEY,dept_name VARCHAR(100) NOT NULL,manager INTEGER FOREIGN KEY (manager) REFERENCES
employee (employee_id))
16
SQL to OWLSQL to OWL
<owl:Class rdf:ID="Department"/>
<owl:ObjectProperty rdf:ID="dept"><rdfs:domain rdf:resource="#Employee"/><rdfs:range rdf:resource="#Department"/>
</owl:ObjectProperty>
<owl:DatatypeProperty rdf:ID="age"><rdf:type rdf:resource="&owl;FunctionalProperty"/><rdfs:domain rdf:resource="#Employee"/><rdfs:range rdf:resource="&xsd;int"/>
</owl:DatatypeProperty>
Table Name
Foreign Key
Attribute
Data type
17
SQL to OWLSQL to OWL<owl:DatatypeProperty rdf:ID="employee_type"> <rdfs:domain rdf:resource="#Employee"/> <rdfs:range>
<owl:DataRange> <owl:oneOf> <rdf:List> <rdf:first rdf:datatype="&xsd;string">Temp</rdf:first>
<rdf:rest> <rdf:List> <rdf:first
rdf:datatype="&xsd;string">Fulltime</rdf:first> <rdf:rest> <rdf:List> <rdf:first
rdf:datatype="&xsd;string">Contract</rdf:first> <rdf:rest rdf:resource="&rdf;nil"/> </rdf:List> </rdf:rest> </rdf:List> </rdf:rest> </rdf:List> </owl:oneOf> </owl:DataRange> </rdfs:range></owl:DatatypeProperty>
Enumerated CheckConstraint
18
SQL to OWLSQL to OWLSQL BNF Shared Semantics
owl:Classowl:ObjectProperty
<table definition> ::= CREATE [ <table scope> ] TABLE <table name> <table contents source> [...]
A table can be an Object Property if acts like a binary relation, or else it is a Class
owl:oneOf <check constraint definition> ::= CHECK <left paren> <search condition> <right paren>
<in predicate> ::= <row value expression> [ NOT ] IN <in predicate value>
The enumerated check constraint represents owl:oneOf
owl:DatatypePropertyowl:FunctionalProperty
owl:maxCardinalityowl:cardinlity
<column definition> ::= <column name> <data type> [NOT NULL] [...]
An attribute is equivalent to a Datatype Property with their domain and range. Depending if the attribute is NOT NULL or not, it can have owl:maxCardinality or owl:cardinality.
owl:ObjectProperty rdfs:domainrdfs:range
owl:FunctionalProperty
<referential constraint definition> ::= FOREIGN KEY <left paren> <referencing columns> <right paren> REFERENCES <referenced table and columns> [...]
Foreign Keys connect to relations, therefore they act as Object Properties with their respective domain and range.
19
Rules: SQL to OWLRules: SQL to OWL
• Binary Relation: a relation that only has two foreign keys (single or composite) referencing two relations.
),,(Re),(),,,(),,,()(Re tsrlBinxsrxtryryAttrsxsrxsrFKtxtrxtrFKrl
• Class: A relation that is not a binary relation is a class.
)(),,(Re)(Re rClassyxrlBinrl • Object Property
– A binary relation is an object property
– A foreign key that references another relation is an object property, whose domain is the current relation and range is the relation that the foreign key references
),(),,(),,()()(),,(Re rrInvstrObjPtsrObjPtClasssClasstsrlBin
),()(),,()(),,()()()(),,,(),(
)(),,()()(),,,(),(
xxInvxFuncPrsxObjPxFuncPsrxObjPsClassrClassxUnisyrxFKsyPK
xFuncPsrxObjPsClassrClasssyrxFKsyPK
20
Rules: SQL to OWLRules: SQL to OWL
• Data type Property: If an attribute is not an object property, then it is a data type property. Its domain is the current relation and the range is the data type.
)1,()())()(,,()(),,,(),()()(Re
)1,()())(,,()(),,,(),()()(Re
)1,()())(,,(),,,(),()()(Re
xMaxCardxFuncPxlistxtyperxDTPxCheckListzyrxFKrxAttrrClassrl
xCardxFuncPxtyperxDTPxNNzyrxFKrxAttrrClassrl
xMaxCardxFuncPxtyperxDTPzyrxFKrxAttrrClassrl
21
SQL to RulesSQL to Rules
• Triggers are business rules and it can not be expressed in OWL
• Should think about how this could be mapped to the rule layer of the Semantic Web
And the final layer cake…
23
Greatest Common Denominator for Data Greatest Common Denominator for Data IntegrationIntegration• All ontologies generated by SQL should
have similar semantic power to facilitate better data integration– Use of different technologies may cause
problems in data integration– The constructs we use has OWL-DL as GCD
• OWL-DL is what SW people like the most.– Reasoning and Inference– Decidability– Computational Completeness
• Therefore OWL-DL should be the target for SQL to Semantic Web transformations.
25
SummarySummary
•SQL has semantics– SQL has been evolving it is a moving
target!– SQL DDL can be used to generate local
ontologies– A Greatest Common Denominator like
OWL-DL can aid with data integration
28
Discussion TopicsDiscussion Topics
• Hierarchy and Inheritance– SQL DDL doesn’t have it– How do database people model it– Not clear how to get the semantics
• CHECK Constraint– Has more semantics that OWL can handle– CHECK (value >0 AND value < 360)
• OWL Constraints– allValuesFrom
someValuesFrom
• URI
29
Discussion Topics: Discussion Topics: Hierarchy and Hierarchy and InheritanceInheritance• Hierarchy and Inheritance
– Integrate information that is spread across several relations (vertical partitioning) and can be either
• Integrated in one concept• Inheritance
But how do you decide!– Key Equality and Data Inclusion: two relations
that share the same primary key and the child relation’s primary key is also a foreign key
PK PK, FK
ProjectSoftwareProject
30
Discussion Topics: Discussion Topics: Hierarchy and Hierarchy and InheritanceInheritance• How do you represent Hierarchy and
Inheritance in database?– Hierarchy: Hand - Finger
PK FK
Hand Finger
– Inheritance: Person - Student
PK PK
Person Student
PK, FK
?
31
Discussion Topics: Discussion Topics: someValuesFrom vs someValuesFrom vs allValuesFromallValuesFrom
A(id, x) B(id, y) C(A_id, B_id)
• Can we say that A and B are classes? Yes• Can we say that C represents an object
property? Yes• Can we say that B can only be connected
to A using the object property? ¿?• Can we say anything about the cardinality
of this relation? ¿?
32
Discussion Topics: Discussion Topics: CHECK ConstraintCHECK Constraint
• Embodies semantics and rules at the same time
• Enumerated CHECK constraint owl:one of
• But what about:– CHECK (value >0 AND value < 360)
33
Translation BNF: SQL to OWLTranslation BNF: SQL to OWL
<sql-owl statement> ::= <class defintion> <property table>| <object property definition>
<class definition> ::= CREATE TABLE <table name>
<object property definition> :: = <object definition> <object property table>
<object definition> ::= CREATE TABLE <table name>
<object property table> ::= <left paren> <object property references> <object property references> <right paren>
<property table>::= <left paren> <property> [ { <comma> <property}...]
<property> ::= <object property>|<datatype property>