OpenLink Virtuoso – RDF Views Exposing SQL Data as RDF
OpenLink Virtuoso Universal Server <ul><li>Cross-platform server for SQL, XML and RDF data management </li></ul><ul><li>In...
Virtuoso RDF Views <ul><li>Expose pre-existing relational data as virtual RDF graphs </li></ul><ul><li>Available for query...
Northwind Demo Database <ul><li>Tables include: </li></ul>Demo.demo.Orders Demo.demo.Customers varchar(24) varchar(24) var...
Northwind Demo Database: RDF View Definition Extract <ul><li>prefix northwind: <http://www.openlinksw.com/schemas/northwin...
Northwind Demo Database: RDF View Definition Extract <ul><li>prefix northwind: <http://www.openlinksw.com/schemas/northwin...
Northwind Demo Database: Customer Table to RDF Entity Mapping Orders Table Germany Country 030 - 0074321 Phone 12209 Posta...
Northwind Demo Database: RDF Browser View – Customer
Northwind Demo Database: RDF Browser View – Order
Example: Product Portfolio – Table View
Example: Product Portfolio – RDF View
Meta-Schema Language <ul><li>RDF Views =  </li></ul><ul><ul><li>Virtuoso RDF Meta-Schema +  </li></ul></ul><ul><ul><li>Met...
MSL Building Blocks <ul><li>Main building blocks: </li></ul><ul><ul><li>Quad map patterns </li></ul></ul><ul><ul><li>IRI c...
Organizational Enhancements <ul><li>Make it easier to administer large sets of quad map patterns </li></ul><ul><li>Group m...
Quad Map Pattern <ul><li>Basic unit of meta schema </li></ul><ul><li>Defines transformation from one set of relational col...
Quad Map Pattern - Example <ul><li>graph <http://www.openlinksw.com/oplweb> </li></ul><ul><li>subject p:product_iri (oplwe...
Named Quad Map Patterns <ul><li>graph <http://www.openlinksw.com/oplweb> </li></ul><ul><li>{ </li></ul><ul><li>p:product_i...
Group Map Patterns <ul><li>Quad map patterns for the same graph can be grouped together into a  group map pattern </li></u...
Quad Storage <ul><li>Quad storage = a named set of quad patterns </li></ul><ul><li>Compartmentalizes the RDF to SQL mappin...
IRI Classes – Creating IRIs from Keys <ul><li>IRI class – constructs a subject IRI for each primary key column value </li>...
IRI Classes – Format Strings <ul><li>sparql </li></ul><ul><li>prefix prd: <http://www.openlinksw.com/schemas/oplweb/produc...
IRI Classes – Complex Conversions <ul><li>For more complex conversions, functions can be specified that assemble and disas...
Literal classes / Identity classes <ul><li>Non-key columns normally form the object of a triple </li></ul><ul><li>Object c...
Quad Pattern Construction Rules <ul><li>An RDF View is defined by combining the building blocks described so far into a co...
A Simple RDF View Definition <ul><li>prefix p: http://www.openlinksw.com/schemas/oplweb/product# </li></ul><ul><li>prefix ...
Additional Meta Schema Language Features <ul><li>Table aliases </li></ul><ul><li>SQL selection and SQL joins through filte...
Table Aliases <ul><li>Provide a concise alternative to fully qualified table names in map patterns </li></ul><ul><li>Decla...
SQL Selection & Joins Through Filters <ul><li>SQL Projection </li></ul><ul><ul><li>Not always desirable to expose all the ...
SQL Selection <ul><li>A quad map pattern can include a  condition </li></ul><ul><ul><li>i.e. a boolean SQL expression </li...
Associating Filters with Table Aliases <ul><li>An alternative to specifying filter conditions directly in quad patterns is...
SQL Joins <ul><li>As well as filtering, a quad map pattern condition can also specify join criteria </li></ul><ul><li>Mult...
Upcoming SlideShare
Loading in …5
×

RDF Views of SQL Data Power Point Presentation - 1

6,015 views
5,840 views

Published on

RDF Views of SQL Data Power Point Presentation

Published in: Technology, Business
0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
6,015
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide

RDF Views of SQL Data Power Point Presentation - 1

  1. 1. OpenLink Virtuoso – RDF Views Exposing SQL Data as RDF
  2. 2. OpenLink Virtuoso Universal Server <ul><li>Cross-platform server for SQL, XML and RDF data management </li></ul><ul><li>Includes </li></ul><ul><ul><li>Virtual database engine </li></ul></ul><ul><ul><li>Web services deployment platform </li></ul></ul><ul><ul><li>Web application server </li></ul></ul><ul><ul><li>SPARQL support and an RDF data store tightly integrated with its relational storage engine </li></ul></ul>
  3. 3. Virtuoso RDF Views <ul><li>Expose pre-existing relational data as virtual RDF graphs </li></ul><ul><li>Available for querying through SPARQL or SPASQL (SPARQL embedded in SQL) </li></ul><ul><li>No physical regeneration of relational data </li></ul>
  4. 4. Northwind Demo Database <ul><li>Tables include: </li></ul>Demo.demo.Orders Demo.demo.Customers varchar(24) varchar(24) varchar(15) varchar(10) varchar(15) varchar(60) varchar(30) varchar(30) varchar(40) varchar(5) Mexico Mexico Germany Country (171) 555 - 7788 (5) 555 -4729 030 - 0074321 Phone 05023 05021 12209 Postal Code Avda. de la Constitucion 2222 Avda. de la Constitucion 2222 Obere Str. 57 Address Mexico D.F. Mexico D.F. Berlin City (5) 555 - 3745 Owner Ana Trujillo Ana Trujillo Emparedados y helados ANATR (171) 555 - 6759 Owner Antonio Moreno Antonio Moreno Taqueria ANTON 030 - 0076545 Sales Represe-ntative Maria Anders Alfreds Futterkiste ALFKI Fax Contact Title Contact Name Company Name Customer ID … 2 1995-11-13 1995-12-01 1995-11-03 4 ALFKI 10692 … … … … 1 Ship Via … 1995-10-23 Required Date … 1995-10-03 Shipped Date … … … 1995-09-25 6 ALFKI 10643 Order Date Employee ID Customer ID Order ID
  5. 5. Northwind Demo Database: RDF View Definition Extract <ul><li>prefix northwind: <http://www.openlinksw.com/schemas/northwind#> </li></ul><ul><li>… </li></ul><ul><li>create iri class northwind:Customer <http://^{URIQADefaultHost}^/Northwind/Customer/%U#this> (in customer_id varchar not null) </li></ul><ul><li>… </li></ul><ul><li>alter quad storage virtrdf:DefaultQuadStorage </li></ul><ul><li>… </li></ul><ul><li>from Demo.demo.Customers as customers </li></ul><ul><li>from Demo.demo.Orders as orders … { </li></ul>Demo.demo.Customers Northwind RDF View Definition create virtrdf:NorthwindDemo as graph iri (“http://^{URIQADefaultHost}^/Northwind”) { … northwind:Customer(customers.CustomerID) a foaf:Organization as virtrdf:Customer-CustomerID ; northwind:companyName customers.CompanyName as … ; … northwind:fax customers.Fax as virtrdf:Customer-fax . … } } northwind:Customer(orders.CustomerID) northwind:has_order northwind:Order(orders.OrderID) as virtrdf:Order-has_order . Country Phone Postal Code Address City Fax Contact Title Contact Name Company Name Customer ID
  6. 6. Northwind Demo Database: RDF View Definition Extract <ul><li>prefix northwind: <http://www.openlinksw.com/schemas/northwind#> </li></ul><ul><li>… </li></ul><ul><li>create iri class northwind:Order <http://^{URIQADefaultHost}^/Northwind/Order/%d#this> (in order_id integer not null) . </li></ul><ul><li>… </li></ul><ul><li>alter quad storage virtrdf:DefaultQuadStorage </li></ul><ul><li>… </li></ul><ul><li>from Demo.demo.Customers as customers </li></ul><ul><li>from Demo.demo.Orders as orders … { </li></ul>Demo.demo.Orders Northwind RDF View Definition create virtrdf:NorthwindDemo as graph iri (“http://^{URIQADefaultHost}^/Northwind”) { … northwind:Order (orders.OrderID) a northwind:Order as virtrdf:Order-Order ; northwind:orderDate orders.OrderDate as virtrdf:Order-order_date ; northwind:requiredDate orders.RequiredDate as virtrdf:Order-required_date ; … … } } northwind:has_customer northwind:Customer (orders.CustomerID) as virtrdf:Order-order_has_customer northwind:has_employee northwind:Employee (orders.EmployeeID) as virtrdf:Order-order_has_employee ; Shipped Via … Required Date Shipped Date Order Date Employee ID Customer ID Order ID
  7. 7. Northwind Demo Database: Customer Table to RDF Entity Mapping Orders Table Germany Country 030 - 0074321 Phone 12209 Postal Code Obere Str. 57 Address Berlin City 030 - 0076545 Sales Represe-ntative Maria Anders Alfreds Futterkiste ALFKI Fax Contact Title Contact Name Company Name Customer ID companyName contactName contactTitle address city PostalCode country phone fax Alfreds Futterkiste Maria Anders Sales Representative Obere Str. 57 Berlin 12209 Germany 030-0074321 030-0076545 … Order/10643#this has_order Order/10692#this … has_order Customer/ALFKI#this prefix <http://demo.openlinksw.com/Northwind/> has_customer has_customer … ALFKI 10643 … ALFKI 10692 … Customer ID Order ID
  8. 8. Northwind Demo Database: RDF Browser View – Customer
  9. 9. Northwind Demo Database: RDF Browser View – Order
  10. 10. Example: Product Portfolio – Table View
  11. 11. Example: Product Portfolio – RDF View
  12. 12. Meta-Schema Language <ul><li>RDF Views = </li></ul><ul><ul><li>Virtuoso RDF Meta-Schema + </li></ul></ul><ul><ul><li>Meta-Schema Language </li></ul></ul><ul><li>MSL = </li></ul><ul><ul><li>A domain specific, declarative language for mapping a logical SQL data model to a conceptual RDF data model </li></ul></ul>
  13. 13. MSL Building Blocks <ul><li>Main building blocks: </li></ul><ul><ul><li>Quad map patterns </li></ul></ul><ul><ul><li>IRI classes </li></ul></ul><ul><ul><li>Literal classes </li></ul></ul><ul><li>Organizational enhancements </li></ul><ul><ul><li>Group map patterns </li></ul></ul><ul><ul><li>Quad storage </li></ul></ul><ul><ul><li>Naming </li></ul></ul>
  14. 14. Organizational Enhancements <ul><li>Make it easier to administer large sets of quad map patterns </li></ul><ul><li>Group map patterns – group together map patterns sharing a common graph </li></ul><ul><li>Quad storage – groups together group map patterns as a named set </li></ul><ul><li>Both allow map patterns to be altered/deleted individually or as a group </li></ul>
  15. 15. Quad Map Pattern <ul><li>Basic unit of meta schema </li></ul><ul><li>Defines transformation from one set of relational columns into triples that match one SPARQL graph pattern </li></ul><ul><li>Comprises 4 declarations of quad map values – each calculates a triple field value from the SQL data </li></ul>
  16. 16. Quad Map Pattern - Example <ul><li>graph <http://www.openlinksw.com/oplweb> </li></ul><ul><li>subject p:product_iri (oplweb2.oplweb.product.product_id) </li></ul><ul><li>predicate p:description </li></ul><ul><li>object oplweb2.oplweb.product.product_description </li></ul><ul><li>Alternative SPARQL-Style Notation </li></ul><ul><li>graph <http://www.openlinksw.com/oplweb> </li></ul><ul><li>{ </li></ul><ul><li>p:product_iri (oplweb2.oplweb.product.product_id) p:description oplweb2.oplweb.product.product_description . </li></ul><ul><li>} </li></ul>
  17. 17. Named Quad Map Patterns <ul><li>graph <http://www.openlinksw.com/oplweb> </li></ul><ul><li>{ </li></ul><ul><li>p:product_iri (oplweb2.oplweb.product.product_id) p:description oplweb2.oplweb.product.product_description </li></ul><ul><li>as virtrdf:product_product_description . </li></ul><ul><li>} </li></ul>
  18. 18. Group Map Patterns <ul><li>Quad map patterns for the same graph can be grouped together into a group map pattern </li></ul><ul><li>create virtrdf:product_portfolio as graph <http://www.openlinksw.com/oplweb> </li></ul><ul><li>{ </li></ul><ul><li>p:product_iri (oplweb2.oplweb.product.product_id) </li></ul><ul><li>a p:Product </li></ul><ul><li>as virtrdf:product_product_id ; </li></ul><ul><li>p:description oplweb2.oplweb.product.product_description </li></ul><ul><li>as virtrdf:product_product_description . </li></ul><ul><li>} </li></ul>group map pattern name
  19. 19. Quad Storage <ul><li>Quad storage = a named set of quad patterns </li></ul><ul><li>Compartmentalizes the RDF to SQL mapping </li></ul><ul><li>Contained quad patterns can be manipulated en-bloc </li></ul><ul><ul><li>drop quad storage storage-name </li></ul></ul><ul><ul><li>create quad storage storage-name { quad-map declarations } </li></ul></ul><ul><ul><li>alter quad storage storage-name { quad-map declarations or drop commands } </li></ul></ul><ul><li>Map patterns can only be created inside a quad storage definition </li></ul>
  20. 20. IRI Classes – Creating IRIs from Keys <ul><li>IRI class – constructs a subject IRI for each primary key column value </li></ul><ul><li>Defines how key values (for atomic or compound key) are combined into / decomposed from an IRI string </li></ul><ul><li>sparql </li></ul><ul><li>prefix prd: <http://www.openlinksw.com/schemas/oplweb/product#> </li></ul><ul><li>create iri class prd:product_iri “http://www.openlinksw.com/oplweb/product#%s” ( </li></ul><ul><li>in product_id varchar not null </li></ul><ul><li>) . </li></ul>
  21. 21. IRI Classes – Format Strings <ul><li>sparql </li></ul><ul><li>prefix prd: <http://www.openlinksw.com/schemas/oplweb/product#> </li></ul><ul><li>create iri class prd:product_iri “http://www.openlinksw.com/oplweb/product#%s” ( </li></ul><ul><li>in product_id varchar not null </li></ul><ul><li>) . </li></ul><ul><li>Sprintf-style format string for performing conversion </li></ul><ul><li>Other format specifiers supported. E.g. %d </li></ul><ul><li>The reverse conversion is inferred automatically </li></ul>
  22. 22. IRI Classes – Complex Conversions <ul><li>For more complex conversions, functions can be specified that assemble and disassemble an IRI from/into its constituent parts </li></ul><ul><li>create iri class prd:product_iri using </li></ul><ul><li>function oplweb2.oplweb.product_uri (in id varchar) </li></ul><ul><li>returns varchar, </li></ul><ul><li>function oplweb2.oplweb.product_uri_inverse (in id_iri varchar) returns varchar . </li></ul><ul><li>Functions product_uri and product_uri inverse would be defined elsewhere in Virtuoso/PL </li></ul>
  23. 23. Literal classes / Identity classes <ul><li>Non-key columns normally form the object of a triple </li></ul><ul><li>Object component of an RDF triple can be an IRI or an RDF literal </li></ul><ul><li>Literal classes create RDF literals from non-key column values </li></ul><ul><li>Identity class = special form of literal class </li></ul><ul><ul><li>Converts a SQL VARCHAR value into an untyped literal </li></ul></ul><ul><ul><li>Converts values of other SQL data types to an appropriate XML Schema typed literal (e.g. xsd:integer or xsd:date) </li></ul></ul><ul><ul><li>Need not be defined explicitly </li></ul></ul><ul><ul><li>Invoked implicitly when a column name is used directly as the object in a quad map pattern </li></ul></ul>
  24. 24. Quad Pattern Construction Rules <ul><li>An RDF View is defined by combining the building blocks described so far into a collection of quad patterns </li></ul><ul><li>Each quad pattern can consist of: </li></ul><ul><ul><li>Subject : an IRI class or constant IRI </li></ul></ul><ul><ul><li>Predicate : a constant IRI or an IRI class </li></ul></ul><ul><ul><li>Object : an IRI class, literal class, literal IRI or a scalar </li></ul></ul><ul><ul><li>Graph : a constant IRI or an IRI class </li></ul></ul><ul><ul><li>Filter : an optional SQL search condition used to filter rows </li></ul></ul>
  25. 25. A Simple RDF View Definition <ul><li>prefix p: http://www.openlinksw.com/schemas/oplweb/product# </li></ul><ul><li>prefix pc: <http://www.openlinksw.com/schemas/oplweb/product_category#> </li></ul><ul><li>alter quad storage virtrdf:DefaultQuadStorage </li></ul><ul><li>from oplweb2.oplweb.product as product_tbl </li></ul><ul><li>from oplweb2.oplweb.product_category as product_category_tbl </li></ul><ul><li>{ </li></ul><ul><li>create virtrdf:product_portfolio as graph <http://www.openlinksw.com/oplweb/> </li></ul><ul><li>{ </li></ul><ul><li>p:product_iri(product_tbl.product_id) a p:Product </li></ul><ul><li>as virtrdf:product_product_id ; </li></ul><ul><li>p:details product_tbl.long_description </li></ul><ul><li>as virtrdf:product_long_description ; </li></ul><ul><li>p:product_category pc:product_category_iri(product_tbl.product_cat_id) </li></ul><ul><li>as virtrdf:product_product_cat_id . </li></ul><ul><li>pc:product_category_iri(product_category_tbl.product_cat_id) </li></ul><ul><li>a pc:ProductCategory </li></ul><ul><li>as virtrdf:product_category_product_cat_id ; </li></ul><ul><li>... </li></ul><ul><li>} . </li></ul><ul><li>} . </li></ul>
  26. 26. Additional Meta Schema Language Features <ul><li>Table aliases </li></ul><ul><li>SQL selection and SQL joins through filters </li></ul>
  27. 27. Table Aliases <ul><li>Provide a concise alternative to fully qualified table names in map patterns </li></ul><ul><li>Declared with a statement such as: </li></ul><ul><li>from oplweb2.oplweb.product as product_tbl </li></ul><ul><li>Declared once at the start of the storage declaration </li></ul><ul><ul><li>Because quad map patterns usually share a common set of source tables </li></ul></ul><ul><ul><li>Shared between all the quad maps defined in the storage declaration </li></ul></ul>
  28. 28. SQL Selection & Joins Through Filters <ul><li>SQL Projection </li></ul><ul><ul><li>Not always desirable to expose all the columns in a table or view </li></ul></ul><ul><ul><ul><li>Security reasons etc. </li></ul></ul></ul><ul><ul><ul><li>Key column value may have no meaning beyond being a unique identifier which is transformed into an IRI </li></ul></ul></ul><ul><ul><li>Obvious – simply : </li></ul></ul><ul><ul><ul><li>omit defining quad map patterns for the relevant columns </li></ul></ul></ul><ul><ul><ul><li>Omit property definitions for these columns in the RDFS class for the table </li></ul></ul></ul>
  29. 29. SQL Selection <ul><li>A quad map pattern can include a condition </li></ul><ul><ul><li>i.e. a boolean SQL expression </li></ul></ul><ul><ul><li>Filters out unwanted rows of source data </li></ul></ul><ul><ul><li>SQL expression includes placeholders where a table reference should be printed </li></ul></ul><ul><li>from oplweb2.oplweb.product as product_tbl </li></ul><ul><li>from oplweb2.oplweb.product_category as product_category_tbl </li></ul><ul><li>graph <http://www.openlinksw.com/oplweb/> </li></ul><ul><li>{ </li></ul><ul><li>. . . </li></ul><ul><li>pc:product_category_iri(product_category_tbl.product_cat_id) </li></ul><ul><li> a pc:ProductCategory </li></ul><ul><li> as virtrdf:product_category_product_cat_id ; </li></ul><ul><li>pc:includes_product p:product_iri(product_tbl.product_id) </li></ul><ul><li> where (^{product_tbl.}^.product_cat_id =^{product_category_tbl.}^.product_cat_id) </li></ul><ul><li> as virtrdf:product_category_product_collection . </li></ul><ul><li>. . . </li></ul><ul><li>} </li></ul>foreign key to IRI conversion primary key to IRI conversion
  30. 30. Associating Filters with Table Aliases <ul><li>An alternative to specifying filter conditions directly in quad patterns is to specify them alongside a table alias </li></ul><ul><li>from DB.DBA.SYS_USERS as user where (^{user.}^.U_IS_ROLE = 0) </li></ul><ul><li>from DB.DBA.SYS_USERS as group where (^{group.}^.U_IS_ROLE = 1) </li></ul><ul><li>All map patterns using the alias are subject to the same filter condition </li></ul><ul><li>If several aliases have associated conditions, the WHERE clause of the generated SQL contains a combination of all relevant conditions </li></ul>
  31. 31. SQL Joins <ul><li>As well as filtering, a quad map pattern condition can also specify join criteria </li></ul><ul><li>Multiple conditions can be associated with a table alias </li></ul><ul><li>For complex joins a quad map pattern can reference a SQL view joining multiple tables </li></ul><ul><li>from DB.DBA.SYS_USERS as user where (^{user.}^.U_IS_ROLE = 0) </li></ul><ul><li>from DB.DBA.SYS_USERS as group where (^{group.}^.U_IS_ROLE = 1) </li></ul><ul><li>from DB.DBA.SYS_USERS as account </li></ul><ul><li>from user as active_user where (^{active_user.}^.U_ACCOUNT_DISABLED = 0) </li></ul><ul><li>from DB.DBA.SYS_ROLE_GRANTS as grant </li></ul><ul><li>where (^{grant.}^.GI_SUPER = ^{account.}^.U_ID) </li></ul><ul><li>where (^{grant.}^.GI_SUB = ^{group.}^.U_ID) </li></ul><ul><li>where (^{grant.}^.GI_SUPER = ^{user.}^.U_ID) </li></ul>

×