目录
1. 结构化数据的知识抽取
2. The D2RQ Mapping Language
2.1. 是什么
2.2. 一个例子:从 MySql 到 Neo4j
2.3. 映射文件语法分析
2.3.1. Database connection (d2rq:Database)
2.3.2. Creating RDF resources (d2rq:ClassMap)
2.3.3. Adding properties to resources (d2rq:PropertyBridge)
2.3.4. 外键(Foreign key)如何体现 (d2rq:PropertyBridge)
2.3.5. 再看个例子
3. 附录
3.1. 附表:iswc 数据库建表语句
3.2. 附表:iswc 库的 D2RQ Mapping 文件
1. 结构化数据的知识抽取
知识抽取是指从不同来源、不同结构的数据中进行知识提取,提取出数据内涵的事实性信息并供给知识图谱做进一步加工处理后会形成知识,存入到知识图谱。
- 非结构化数据
- 半结构化数据
- 结构化数据
结构化数据就是指类似于关系库中表格形式的数据,该类数据往往在各项之间存在明确的关系名称和对应关系。
2. The D2RQ Mapping Language
2.1. 是什么
The D2RQ Mapping Language is a declarative language for describing the relation between a relational database schema and RDFS vocabularies or OWL ontologies.
A D2RQ mapping is itself an RDF document written in Turtle syntax. The mapping is expressed using terms in the D2RQ namespace:
代码语言:javascript复制http://www.wiwiss.fu-berlin.de/suhl/bizer/D2RQ/0.1#
The mapping defines a virtual RDF graph that contains information from the database. This is similar to the concept of views in SQL, except that the virtual data structure is an RDF graph instead of a virtual relational table.
2.2. 一个例子:从 MySql 到 Neo4j
- 步骤1:构建 MySql 数据库
参考 “附表:iswc 数据库建表语句”
- 步骤2:使用 generate-mapping 产生数据库映射文件
参考 “附表:iswc 库的 D2RQ Mapping 文件
代码语言:javascript复制generate-mapping -u root -p oracledba -o iswc.ttl "jdbc:mysql://localhost:3306/iswc?rewriteBatchedStatements=true&characterEncoding=utf8&serverTimezone=GMT+8&useSSL=false"
- 步骤3:使用 dump-rdf 将数据库内容转换为 RDF(注意里面的 -b 参数)
dump-rdf -f TURTLE -b http://www.webj2eedev.com/iswc/ -o iswc.nt iswc.ttl
- 步骤4:借助 neosemantics (n10s) 将 RDF 导入 Neo4j
call n10s.graphconfig.init()
call n10s.rdf.import.fetch( "file:///F:\iswc.nt","Turtle")
- 步骤5:在 Neo4j 中查看(例如:查看生成的所有 Class)
2.3. 映射文件语法分析
2.3.1. Database connection (d2rq:Database)
- A d2rq:Database defines a JDBC connection to a local or remote relational database.
- A D2RQ map can contain several d2rq:Databases for accessing different databases.
- Most JDBC drivers offer a range of JDBC connection properties, which specify advanced configuration options for the JDBC database connection. A D2RQ mapping file can be made to use arbitrary connection properties when setting up the JDBC connection. This is done through the jdbc: namespace (namespace URI: http://d2rq.org/terms/jdbc/). RDF properties in that namespace will be passed as connection properties. Consult your JDBC driver's documentation for a list of available properties.
语法:
示例:
2.3.2. Creating RDF resources (d2rq:ClassMap)
- A d2rq:ClassMap represents a class or a group of similar classes of an OWL ontology or RDFS schema. A class map defines how instances of the class are identified. It is connected to a d2rq:Database and has a set of d2rq:PropertyBridges which attach properties to the instances.
- A URI pattern is instantiated by inserting values of certain database columns into a pattern. The parts between @@'s mark database columns in Table.Column notation. URI patterns are used with the d2rq:uriPattern property.
http://example.org/persons/@@Persons.ID@@
http://example.org/lineItems/item@@Orders.orderID@@-@@LineItems.itemID@@
urn:isbn:@@Books.isbn@@
mailto:@@Persons.email@@
关键语法:
示例:
图示1:表如何映射(conferences表)
2.3.3. Adding properties to resources (d2rq:PropertyBridge)
A d2rq:PropertyBridge relates a database column to an RDF property. Property bridges are used to attach properties to the RDF resources created by a class map.
If the one of the columns used in a property bridge is NULL for some database rows, then no property is created for the resources corresponding to these rows.
关键语法:
图示1:数据行如何映射(conferences表)
2.3.4. 外键(Foreign key)如何体现 (d2rq:PropertyBridge)
代码语言:javascript复制map:authorName a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:Papers;
d2rq:property :authorName;
d2rq:column "Persons.Name";
d2rq:join "Papers.PaperID <= Rel_Person_Paper.PaperID";
d2rq:join "Rel_Person_Paper.PersonID => Persons.PerID";
d2rq:datatype xsd:string;
d2rq:propertyDefinitionLabel "name"@en;
d2rq:propertyDefinitionComment "Name of an author."@en;
.
This property bridge adds the names of authors to papers. If a paper has several authors, then several :authorName properties are added. The tables Papers and Persons are in an n:m relation. The d2rq:join is used to join the tables over the Rel_Person_Paper. The join condition contains directed arrows that indicate the foreign key relationship and are used as an optimization hint. In the example above, the arrow directions indicate that all possible values of Rel_Person_Paper.PaperID and Rel_Person_Paper.PersonID are present in Papers.PaperID and Persons.PerID, respectively. Where this is unclear, a simple equation sign (=) may be used.
关键语法:
示例:
2.3.5. 再看个例子
- 特点:表中的列,不全都是外键。
3. 附录
3.1. 附表:iswc 数据库建表语句
代码语言:javascript复制-- phpMyAdmin SQL Dump
-- version 2.9.1.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Feb 21, 2007 at 07:04 PM
-- Server version: 5.0.27
-- PHP Version: 5.2.0
--
-- Database: `iswc`
--
-- --------------------------------------------------------
--
-- Table structure for table `conferences`
--
CREATE TABLE `conferences` (
`ConfID` int(11) NOT NULL default '0',
`Name` varchar(100) default NULL,
`URI` varchar(200) default NULL,
`Date` varchar(50) default NULL,
`Location` varchar(50) default NULL,
`Datum` datetime default NULL,
PRIMARY KEY (`ConfID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `conferences`
--
INSERT INTO `conferences` (`ConfID`, `Name`, `URI`, `Date`, `Location`, `Datum`) VALUES
(23541, 'International Semantic Web Conference 2002', 'http://annotation.semanticweb.org/iswc/iswc.daml#ISWC_2002', 'June 9-12, 2002', 'Sardinia', '2002-10-09 00:00:00'),
(23542, '15th International World Wide Web Conference', NULL, 'May 23-26, 2006', 'Edinburgh', '2006-05-23 00:00:00');
-- --------------------------------------------------------
--
-- Table structure for table `organizations`
--
CREATE TABLE `organizations` (
`OrgID` int(11) NOT NULL default '0',
`Type` varchar(50) default NULL,
`Name` varchar(200) default NULL,
`Address` mediumtext,
`Location` varchar(50) default NULL,
`Postcode` varchar(10) default NULL,
`Country` varchar(50) default NULL,
`URI` varchar(100) default NULL,
`Belongsto` int(11) default NULL,
`Homepage` varchar(200) default NULL,
PRIMARY KEY (`OrgID`),
KEY `Belongsto` (`Belongsto`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `organizations`
--
INSERT INTO `organizations` (`OrgID`, `Type`, `Name`, `Address`, `Location`, `Postcode`, `Country`, `URI`, `Belongsto`, `Homepage`) VALUES
(1, NULL, 'USC Information Sciences Institute', '4676 Admirality Way', 'Marina Del Rey', NULL, 'United States', 'http://trellis.semanticweb.org/expect/web/semanticweb/iswc02_trellis.pdf#ISI', NULL, NULL),
(2, 'U', 'University of Karlsruhe', NULL, NULL, NULL, NULL, 'http://annotation.semanticweb.org/iswc/iswc.daml#University_of_Karlsruhe', NULL, NULL),
(3, 'U', 'International University in Germany', NULL, NULL, NULL, NULL, 'http://www.i-u.de/schools/eberhart/iswc2002/#International University in Germany', NULL, NULL),
(4, 'I', 'AIFB', NULL, 'Karlsruhe', NULL, 'Germany', 'http://annotation.semanticweb.org/iswc/iswc.daml#AIFB', NULL, 'http://www.aifb.uni-karlsruhe.de/'),
(5, 'D', 'Department of Computer Science', 'De Boelelaan 1081a', 'Amsterdam', '1081 HV', 'The Netherlands', 'http://www.cs.vu.nl/~borys/papers/abstracts/ISWC2002.html#CSVUNL', 6, NULL),
(6, 'U', 'Vrije Universiteit Amsterdam', 'De Boelelaan 1105', 'Amsterdam', '1081 HV', 'The Netherlands', 'http://www.cs.vu.nl/~borys/papers/abstracts/ISWC2002.html#VrijeUniversiteitAmsterdam', NULL, NULL),
(7, NULL, 'Hewlett-Packard Laboratories, Bristol', 'Filton Road', 'Bristol', 'BS34 8QZ', 'UK', 'http://www.hpl.hp.co.uk#HPL', NULL, 'http://www.hpl.hp.com/'),
(8, 'I', 'Institute for the Protection and Security of the Citizen', 'Via Enrico Fermi, 1n21020 - Ispra (Italy)', NULL, NULL, NULL, 'http://dma.jrc.it#Institute for the Protection and Security of the Citizen', NULL, NULL),
(9, 'D', 'Dipartimento di Ingegneria dell''Informazione', 'Via Vignolese 905', 'Modena', NULL, 'Italy', 'http://www.dbgroup.unimo.it/iswc/iswc.html#DII', NULL, NULL);
-- --------------------------------------------------------
--
-- Table structure for table `papers`
--
CREATE TABLE `papers` (
`PaperID` int(11) NOT NULL default '0',
`Title` varchar(200) default NULL,
`Abstract` mediumtext,
`URI` varchar(200) default NULL,
`Year` int(11) default NULL,
`Conference` int(11) default NULL,
`Publish` tinyint(1) default NULL,
PRIMARY KEY (`PaperID`),
KEY `Conference` (`Conference`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `papers`
--
INSERT INTO `papers` (`PaperID`, `Title`, `Abstract`, `URI`, `Year`, `Conference`, `Publish`) VALUES
(1, 'Trusting Information Sources One Citizen at a Time', 'This paper describes an approach to derive assessments about information n sources based on individual feedback about the sources. We describe n TRELLIS, a system that helps users annotate their analysis of n alternative information sources that can be contradictory and n incomplete. As the user makes a decision on which sources to dismiss and n which to believe in making a final decision, TRELLIS captures the n derivation of the decision in a semantic markup. TRELLIS then uses these n annotations to derive an assessment of the source based on the n annotations of many individuals. Our work builds on the Semantic Web and n presents a tool that helps users create annotations that are in a mix of n formal and human language, and exploits the formal representations to n derive measures of trust in the content of Web resources and their n original source.', 'http://trellis.semanticweb.org/expect/web/semanticweb/iswc02_trellis.pdf#Trusting Information Sources One Citizen at a Time', 2002, 23541, 1),
(2, 'Automatic Generation of Java/SQL based Inference Engines from RDF Schema and RuleML', 'This paper describes two approaches for automatically converting RDF Schema nand RuleML sources into an inference engine and storage repository. Rather than nusing traditional inference systems, our solution bases on mainstream ntechnologies like Java and relational database systems. While this necessarily nimposes some restrictions, the ease of integration into an existing IT landscape nis a major advantage. We present the conversion tools and their limitations. nFurthermore, an extension to RuleML is proposed, that allows Java-enabled nreaction rules, where calls to Java libraries can be performed upon a rule nfiring. This requires hosts to be Java-enabled when rules and code are moved nacross the web. However, the solution allows for great engineering nflexibility.', 'http://www.i-u.de/schools/eberhart/iswc2002/#Automatic Generation of Java/SQL based Inference Engines from RDF Schema and RuleML', 2002, 23541, 1),
(4, 'Three Implementations of SquishQL, a Simple RDF Query Language', 'RDF provides a basic way to represent data for the Semantic Web. We have n been experimenting with the query paradigm for working with RDF data in n semantic web applications. Query of RDF data provides a declarative n access mechanism that is suitable for application usage and remote n access. We describe work on a conceptual model for querying RDF data n that refines ideas first presented in at the W3C workshop on Query n Languages and the design of one possible syntax, derived from rdfDB, n that is suitable for application programmers. Further, we present n experience gained in three implementations of the query language.', 'http://www-uk.hpl.hp.com/people/afs/Abstracts/ISWC2002-SquishQL-Abstract.html#SquishQL', 2003, 23541, 1),
(5, 'A Data Integration Framework for E-commerce Product Classification', 'A marketplace is n the place in which the demand and supply of buyers and vendors n participating in a business process may meet. Therefore, electronic n marketplaces are virtual communities in which buyers may meet proposals n of several suppliers and make the best choice. In the electronic n commerce world, the comparison between different products is blocked due n to the lack of standards (on the contrary, the proliferation of n standards) describing and classifying them. Therefore, the need for B2B n and B2C marketplaces is to reclassify products and goods according to n different standardization models. This paper aims to face this problem n by suggesting the use of a semi-automatic methodology, supported by a n tool (SI-Designer), to define the mapping among different e-commerce n product classification standards. This methodology was developed for the n MOMIS-system within the Intelligent Integration of Information research n area. We describe our extension to the methodology that makes it n applyable in general to product classification standard, by selecting a n fragment of ECCMA/UNSPSC and ecl@ss standard.', 'http://www.dbgroup.unimo.it/iswc/iswc.html#A Data Integration Framework for E-commerce Product Classification', 2002, 23541, 1),
(6, 'Integrating Vocabularies: Discovering and Representing Vocabulary Maps', 'The Semantic Web would enable new ways of doing business on the<br>Web n that require development of advanced business document<br>integration n technologies performing intelligent document<br>transformation. The n documents use different vocabularies that<br>consist of large n hierarchies of terms. Accordingly, vocabulary<br>mapping and n transformation becomes an important task in the whole<br>business n document transformation process. It includes several<br>subtasks: map n discovery, map representation, and map execution<br>that must be n seamlessly integrated into the document integration<br>process. In this n paper we discuss the process of discovering the<br>maps between two n vocabularies assuming availability of two sets of<br>documents, each n using one of the vocabularies. We take the<br>vocabularies of product n classification codes as a playground and<br>propose a reusable map n discovery technique based on Bayesian text<br>classification approach. n We show how the discovered maps can be<br>integrated into the document n transformation process.', 'http://www.cs.vu.nl/~borys/papers/abstracts/ISWC2002.html#OmelayenkoISWC2002', 2003, 23541, 0),
(7, 'The Semantic Web Revisited', 'The original Scientific American article on the Semantic Web appeared in 2001. It described the evolution of a Web that consisted largely of documents for humans to read to one that included data and information for computers to manipulate. The Semantic Web is a Web of actionable information--information derived from data through a semantic theory for interpreting the symbols.This simple idea, however, remains largely unrealized. Shopbots and auction bots abound on the Web, but these are essentially handcrafted for particular tasks; they have little ability to interact with heterogeneous data and information types. Because we haven''t yet delivered large-scale, agent-based mediation, some commentators argue that the Semantic Web has failed to deliver. We argue that agents can only flourish when standards are well established and that the Web standards for expressing shared meaning have progressed steadily over the past five years. Furthermore, we see the use of ontologies in the e-science community presaging ultimate success for the Semantic Web--just as the use of HTTP within the CERN particle physics community led to the revolutionary success of the original Web. This article is part of a special issue on the Future of AI.', 'http://eprints.ecs.soton.ac.uk/12614/01/Semantic_Web_Revisted.pdf', 2006, NULL, 1),
(8, 'D2R Server - Publishing Relational Databases on the Web as SPARQL Endpoints', 'The Resource Description Framework and the SPARQL query language provide a standardized way for exposing and linking data sources on the Web. D2R Server is a turn-key solution for making the content of existing, non-RDF databases accessible as SPARQL endpoints. The server takes SPARQL queries from the Web and rewrites them via a mapping into SQL queries against a relational database. This on-the-fly translation allows RDF applications to access the content of large databases without having to replicate them into RDF. D2R Server can be used to integrate existing databases into RDF systems, and to add SPARQL interfaces to database-backed software products. In the talk, we will give an introduction into the D2RQ mapping language, which is used to define mappings between relational and RDF schemata, and demonstrate how D2R Server can be used to extend a WordPress blog with a SPARQL interface.', 'http://www.wiwiss.fu-berlin.de/suhl/bizer/d2r-server/resources/d2r-server-slides-www2006.pdf', 2006, 23542, 1);
-- --------------------------------------------------------
--
-- Table structure for table `persons`
--
CREATE TABLE `persons` (
`PerID` int(11) NOT NULL default '0',
`Type` varchar(50) default NULL,
`FirstName` varchar(100) default NULL,
`LastName` varchar(100) default NULL,
`Address` varchar(200) default NULL,
`Email` varchar(100) default NULL,
`Homepage` varchar(50) default NULL,
`Phone` varchar(200) default NULL,
`URI` varchar(200) default NULL,
`Photo` varchar(200) default NULL,
PRIMARY KEY (`PerID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `persons`
--
INSERT INTO `persons` (`PerID`, `Type`, `FirstName`, `LastName`, `Address`, `Email`, `Homepage`, `Phone`, `URI`, `Photo`) VALUES
(1, 'Full_Professor', 'Yolanda', 'Gil', NULL, 'gil@isi.edu', 'http://www.isi.edu/~gil', '310-448-8794', 'http://trellis.semanticweb.org/expect/web/semanticweb/iswc02_trellis.pdf#Yolanda Gil', 'http://www.isi.edu/~gil/y.g.v4.tiff'),
(2, NULL, 'Varun', 'Ratnakar', NULL, 'varunr@isi.edu', 'http://www.isi.edu/~varunr', NULL, 'http://trellis.semanticweb.org/expect/web/semanticweb/iswc02_trellis.pdf#Varun Ratnakar', NULL),
(3, 'Researcher', 'Jim', 'Blythe', NULL, 'blythe@isi.edu', 'http://www.isi.edu/~varunr', NULL, 'http://trellis.semanticweb.org/expect/web/semanticweb/iswc02_trellis.pdf#Jim Blythe', NULL),
(4, 'Researcher', 'Andreas', 'Eberhart', 'International University in Germany Campus 2 76646 Bruchsal Germany', 'eberhart@i-u.de', 'http://www.i-u.de/schools/eberhart/', ' 49 7251 700 222', 'http://www.i-u.de/schools/eberhart/iswc2002/#Andreas Eberhart', NULL),
(5, 'Researcher', 'Borys', 'Omelayenko', 'Vrije Universiteit, Division of Mathematics and Computer Science, De Boelelaan 1081a,1081hv, Amsterdam, The Netherlands', 'borys@cs.vu.nl', 'http://www.cs.vu.nl/~borys', NULL, 'http://www.cs.vu.nl/~borys#Bomelayenko', NULL),
(6, 'Researcher', 'Andy', 'Seaborne', 'Hewlett-Packard Laboratories, Bristol, BS34 8QZ, UK', 'andy.seaborne@hpl.hp.com', 'http://www-uk.hpl.hp.com/people/afs/', NULL, 'http://www-uk.hpl.hp.com/people#andy_seaborne', 'http://semtech2011.semanticweb.com/uploads/images/bios/3205.jpg'),
(9, NULL, 'Alberto', 'Reggiori', NULL, 'areggiori@webweaving.org', 'http://reggiori.webweaving.org/', NULL, 'http://reggiori.webweaving.org#Alberto Reggiori', NULL),
(10, 'Full_Professor', 'Sonia', 'Bergamaschi', 'DII- Universita di Modena e Reggio Emilia via Vignolese 905 41100 Modena', 'bergamaschi.sonia@unimo.it', 'http://www.dbgroup.unimo.it/Bergamaschi.html', ' 39 059 2056132', 'http://www.dbgroup.unimo.it/iswc/iswc.html#S. Bergamaschi', NULL),
(11, NULL, 'Francesco', 'Guerra', 'DII- Universita di Modena e Reggio Emilia via Vignolese 905 41100 Modena Italy', 'guerra.francesco@unimo.it', 'http://www.dbgroup.unimo.it/~guerra/', ' 39 059 20561543', 'http://www.dbgroup.unimo.it/iswc/iswc.html#F. Guerra', NULL),
(12, 'Researcher', 'Christian', 'Bizer', 'Freie Universität Berlin', 'chris@bizer.de', 'http://www.bizer.de/', NULL, 'http://www.bizer.de/foaf.rdf#chris', 'http://www.wiwiss.fu-berlin.de/en/institute/pwo/bizer/pics/bizer_christian_200x300.png');
-- --------------------------------------------------------
--
-- Table structure for table `rel_paper_topic`
--
CREATE TABLE `rel_paper_topic` (
`PaperID` int(11) NOT NULL default '0',
`TopicID` int(11) NOT NULL default '0',
`RelationType` int(11) default NULL,
PRIMARY KEY (`PaperID`,`TopicID`),
KEY `TopicID` (`TopicID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `rel_paper_topic`
--
INSERT INTO `rel_paper_topic` (`PaperID`, `TopicID`, `RelationType`) VALUES
(1, 5, 1),
(1, 15, 2),
(2, 3, 3),
(2, 5, 2),
(4, 10, 2),
(4, 11, 1),
(4, 14, 2),
(5, 2, 3),
(5, 3, 1),
(5, 13, 2),
(6, 5, 2),
(6, 11, 1),
(6, 13, 3);
-- --------------------------------------------------------
--
-- Table structure for table `rel_person_organization`
--
CREATE TABLE `rel_person_organization` (
`PersonID` int(11) NOT NULL default '0',
`OrganizationID` int(11) NOT NULL default '0',
PRIMARY KEY (`PersonID`,`OrganizationID`),
KEY `OrganizationID` (`OrganizationID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `rel_person_organization`
--
INSERT INTO `rel_person_organization` (`PersonID`, `OrganizationID`) VALUES
(1, 1),
(2, 1),
(3, 1),
(4, 3),
(5, 5),
(5, 6),
(6, 7),
(9, 8),
(10, 9),
(11, 9);
-- --------------------------------------------------------
--
-- Table structure for table `rel_person_paper`
--
CREATE TABLE `rel_person_paper` (
`PersonID` int(11) NOT NULL default '0',
`PaperID` int(11) NOT NULL default '0',
PRIMARY KEY (`PersonID`,`PaperID`),
KEY `PaperID` (`PaperID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `rel_person_paper`
--
INSERT INTO `rel_person_paper` (`PersonID`, `PaperID`) VALUES
(1, 1),
(2, 1),
(4, 2),
(6, 4),
(9, 4),
(10, 5),
(11, 5),
(5, 6),
(12, 8);
-- --------------------------------------------------------
--
-- Table structure for table `rel_person_topic`
--
CREATE TABLE `rel_person_topic` (
`PersonID` int(11) NOT NULL default '0',
`TopicID` int(11) NOT NULL default '0',
PRIMARY KEY (`PersonID`,`TopicID`),
KEY `TopicID` (`TopicID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `rel_person_topic`
--
INSERT INTO `rel_person_topic` (`PersonID`, `TopicID`) VALUES
(1, 1),
(3, 1),
(4, 1),
(1, 2),
(3, 2),
(1, 3),
(3, 3),
(2, 5),
(5, 5),
(6, 5),
(9, 5),
(10, 5),
(11, 5),
(2, 6),
(2, 7),
(5, 7),
(2, 8),
(10, 10),
(11, 10),
(5, 13),
(10, 15);
-- --------------------------------------------------------
--
-- Table structure for table `topics`
--
CREATE TABLE `topics` (
`TopicID` int(11) NOT NULL default '0',
`TopicName` varchar(50) default NULL,
`URI` varchar(200) default NULL,
`ParentID` int(11) default NULL,
PRIMARY KEY (`TopicID`),
KEY `ParentID` (`ParentID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `topics`
--
INSERT INTO `topics` (`TopicID`, `TopicName`, `URI`, `ParentID`) VALUES
(1, 'Knowledge Representation Languages', 'http://annotation.semanticweb.org/iswc/iswc.daml#Knowledge_Representation_Languages', 3),
(2, 'Knowledge Systems', 'http://annotation.semanticweb.org/iswc/iswc.daml#Knowledge_Systems', 15),
(3, 'Artificial Intelligence', 'http://annotation.semanticweb.org/iswc/iswc.daml#Artificial_Intelligence', NULL),
(4, 'Semantic Annotation', 'http://annotation.semanticweb.org/iswc/iswc.daml#Semantic_Annotation', 5),
(5, 'Semantic Web', 'http://annotation.semanticweb.org/iswc/iswc.daml#Semantic_Web', 8),
(6, 'Semantic Web Languages', 'http://annotation.semanticweb.org/iswc/iswc.daml#Semantic_Web_Languages', 5),
(7, 'Web Services', 'http://annotation.semanticweb.org/iswc/iswc.daml#Web_Services', 8),
(8, 'World Wide Web', 'http://annotation.semanticweb.org/iswc/iswc.daml#World_Wide_Web', NULL),
(9, 'Text Mining', 'http://annotation.semanticweb.org/iswc/iswc.daml#Text_Mining', 16),
(10, 'Databases', 'http://annotation.semanticweb.org/iswc/iswc.daml#Databases', NULL),
(11, 'Semantic Web Infrastructure', 'http://annotation.semanticweb.org/iswc/iswc.daml#Semantic_Web_Iinfrastructure', 5),
(13, 'E-Business', 'http://annotation.semanticweb.org/iswc/iswc.daml#e-Business', NULL),
(14, 'Query Languages', 'http://annotation.semanticweb.org/iswc/iswc.daml#Query_Languages', 16),
(15, 'Knowledge Management', 'http://annotation.semanticweb.org/iswc/iswc.daml#Knowledge_Management', NULL),
(16, 'Knowledge Discovery', 'http://annotation.semanticweb.org/iswc/iswc.daml#Knowledge_Discovery', 3);
--
-- Constraints for dumped tables
--
--
-- Constraints for table `organizations`
--
ALTER TABLE `organizations`
ADD CONSTRAINT `organizations_ibfk_1` FOREIGN KEY (`Belongsto`) REFERENCES `organizations` (`OrgID`);
--
-- Constraints for table `papers`
--
ALTER TABLE `papers`
ADD CONSTRAINT `papers_ibfk_1` FOREIGN KEY (`Conference`) REFERENCES `conferences` (`ConfID`);
--
-- Constraints for table `rel_paper_topic`
--
ALTER TABLE `rel_paper_topic`
ADD CONSTRAINT `rel_paper_topic_ibfk_1` FOREIGN KEY (`PaperID`) REFERENCES `papers` (`PaperID`),
ADD CONSTRAINT `rel_paper_topic_ibfk_2` FOREIGN KEY (`TopicID`) REFERENCES `topics` (`TopicID`);
--
-- Constraints for table `rel_person_organization`
--
ALTER TABLE `rel_person_organization`
ADD CONSTRAINT `rel_person_organization_ibfk_1` FOREIGN KEY (`PersonID`) REFERENCES `persons` (`PerID`),
ADD CONSTRAINT `rel_person_organization_ibfk_2` FOREIGN KEY (`OrganizationID`) REFERENCES `organizations` (`OrgID`);
--
-- Constraints for table `rel_person_paper`
--
ALTER TABLE `rel_person_paper`
ADD CONSTRAINT `rel_person_paper_ibfk_1` FOREIGN KEY (`PersonID`) REFERENCES `persons` (`PerID`),
ADD CONSTRAINT `rel_person_paper_ibfk_2` FOREIGN KEY (`PaperID`) REFERENCES `papers` (`PaperID`);
--
-- Constraints for table `rel_person_topic`
--
ALTER TABLE `rel_person_topic`
ADD CONSTRAINT `rel_person_topic_ibfk_1` FOREIGN KEY (`PersonID`) REFERENCES `persons` (`PerID`),
ADD CONSTRAINT `rel_person_topic_ibfk_2` FOREIGN KEY (`TopicID`) REFERENCES `topics` (`TopicID`);
--
-- Constraints for table `topics`
--
ALTER TABLE `topics`
ADD CONSTRAINT `topics_ibfk_1` FOREIGN KEY (`ParentID`) REFERENCES `topics` (`TopicID`);
3.2. 附表:iswc 库的 D2RQ Mapping 文件
代码语言:javascript复制@prefix map: <#> .
@prefix db: <> .
@prefix vocab: <vocab/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix d2rq: <http://www.wiwiss.fu-berlin.de/suhl/bizer/D2RQ/0.1#> .
@prefix jdbc: <http://d2rq.org/terms/jdbc/> .
map:database a d2rq:Database;
d2rq:jdbcDriver "com.mysql.jdbc.Driver";
d2rq:jdbcDSN "jdbc:mysql://localhost:3306/iswc?rewriteBatchedStatements=true&characterEncoding=utf8&serverTimezone=GMT+8&useSSL=false";
d2rq:username "root";
d2rq:password "oracledba";
jdbc:zeroDateTimeBehavior "convertToNull";
jdbc:autoReconnect "true";
.
# Table conferences
map:conferences a d2rq:ClassMap;
d2rq:dataStorage map:database;
d2rq:uriPattern "conferences/@@conferences.ConfID@@";
d2rq:class vocab:conferences;
d2rq:classDefinitionLabel "conferences";
.
map:conferences__label a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:conferences;
d2rq:property rdfs:label;
d2rq:pattern "conferences #@@conferences.ConfID@@";
.
map:conferences_ConfID a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:conferences;
d2rq:property vocab:conferences_ConfID;
d2rq:propertyDefinitionLabel "conferences ConfID";
d2rq:column "conferences.ConfID";
d2rq:datatype xsd:integer;
.
map:conferences_Name a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:conferences;
d2rq:property vocab:conferences_Name;
d2rq:propertyDefinitionLabel "conferences Name";
d2rq:column "conferences.Name";
.
map:conferences_URI a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:conferences;
d2rq:property vocab:conferences_URI;
d2rq:propertyDefinitionLabel "conferences URI";
d2rq:column "conferences.URI";
.
map:conferences_Date a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:conferences;
d2rq:property vocab:conferences_Date;
d2rq:propertyDefinitionLabel "conferences Date";
d2rq:column "conferences.Date";
.
map:conferences_Location a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:conferences;
d2rq:property vocab:conferences_Location;
d2rq:propertyDefinitionLabel "conferences Location";
d2rq:column "conferences.Location";
.
map:conferences_Datum a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:conferences;
d2rq:property vocab:conferences_Datum;
d2rq:propertyDefinitionLabel "conferences Datum";
d2rq:column "conferences.Datum";
d2rq:datatype xsd:dateTime;
.
# Table organizations
map:organizations a d2rq:ClassMap;
d2rq:dataStorage map:database;
d2rq:uriPattern "organizations/@@organizations.OrgID@@";
d2rq:class vocab:organizations;
d2rq:classDefinitionLabel "organizations";
.
map:organizations__label a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:organizations;
d2rq:property rdfs:label;
d2rq:pattern "organizations #@@organizations.OrgID@@";
.
map:organizations_Type a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:organizations;
d2rq:property vocab:organizations_Type;
d2rq:propertyDefinitionLabel "organizations Type";
d2rq:column "organizations.Type";
.
map:organizations_Name a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:organizations;
d2rq:property vocab:organizations_Name;
d2rq:propertyDefinitionLabel "organizations Name";
d2rq:column "organizations.Name";
.
map:organizations_Address a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:organizations;
d2rq:property vocab:organizations_Address;
d2rq:propertyDefinitionLabel "organizations Address";
d2rq:column "organizations.Address";
.
map:organizations_Location a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:organizations;
d2rq:property vocab:organizations_Location;
d2rq:propertyDefinitionLabel "organizations Location";
d2rq:column "organizations.Location";
.
map:organizations_Postcode a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:organizations;
d2rq:property vocab:organizations_Postcode;
d2rq:propertyDefinitionLabel "organizations Postcode";
d2rq:column "organizations.Postcode";
.
map:organizations_Country a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:organizations;
d2rq:property vocab:organizations_Country;
d2rq:propertyDefinitionLabel "organizations Country";
d2rq:column "organizations.Country";
.
map:organizations_URI a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:organizations;
d2rq:property vocab:organizations_URI;
d2rq:propertyDefinitionLabel "organizations URI";
d2rq:column "organizations.URI";
.
map:organizations_Homepage a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:organizations;
d2rq:property vocab:organizations_Homepage;
d2rq:propertyDefinitionLabel "organizations Homepage";
d2rq:column "organizations.Homepage";
.
map:organizations_Belongsto__ref a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:organizations;
d2rq:property vocab:organizations_Belongsto;
d2rq:refersToClassMap map:organizations;
d2rq:alias "organizations AS organizations__alias";
d2rq:join "organizations.Belongsto => organizations__alias.OrgID";
.
# Table papers
map:papers a d2rq:ClassMap;
d2rq:dataStorage map:database;
d2rq:uriPattern "papers/@@papers.PaperID@@";
d2rq:class vocab:papers;
d2rq:classDefinitionLabel "papers";
.
map:papers__label a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:papers;
d2rq:property rdfs:label;
d2rq:pattern "papers #@@papers.PaperID@@";
.
map:papers_PaperID a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:papers;
d2rq:property vocab:papers_PaperID;
d2rq:propertyDefinitionLabel "papers PaperID";
d2rq:column "papers.PaperID";
d2rq:datatype xsd:integer;
.
map:papers_Title a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:papers;
d2rq:property vocab:papers_Title;
d2rq:propertyDefinitionLabel "papers Title";
d2rq:column "papers.Title";
.
map:papers_Abstract a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:papers;
d2rq:property vocab:papers_Abstract;
d2rq:propertyDefinitionLabel "papers Abstract";
d2rq:column "papers.Abstract";
.
map:papers_URI a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:papers;
d2rq:property vocab:papers_URI;
d2rq:propertyDefinitionLabel "papers URI";
d2rq:column "papers.URI";
.
map:papers_Year a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:papers;
d2rq:property vocab:papers_Year;
d2rq:propertyDefinitionLabel "papers Year";
d2rq:column "papers.Year";
d2rq:datatype xsd:integer;
.
map:papers_Publish a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:papers;
d2rq:property vocab:papers_Publish;
d2rq:propertyDefinitionLabel "papers Publish";
d2rq:column "papers.Publish";
d2rq:datatype xsd:boolean;
.
map:papers_Conference__ref a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:papers;
d2rq:property vocab:papers_Conference;
d2rq:refersToClassMap map:conferences;
d2rq:join "papers.Conference => conferences.ConfID";
.
# Table persons
map:persons a d2rq:ClassMap;
d2rq:dataStorage map:database;
d2rq:uriPattern "persons/@@persons.PerID@@";
d2rq:class vocab:persons;
d2rq:classDefinitionLabel "persons";
.
map:persons__label a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:persons;
d2rq:property rdfs:label;
d2rq:pattern "persons #@@persons.PerID@@";
.
map:persons_PerID a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:persons;
d2rq:property vocab:persons_PerID;
d2rq:propertyDefinitionLabel "persons PerID";
d2rq:column "persons.PerID";
d2rq:datatype xsd:integer;
.
map:persons_Type a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:persons;
d2rq:property vocab:persons_Type;
d2rq:propertyDefinitionLabel "persons Type";
d2rq:column "persons.Type";
.
map:persons_FirstName a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:persons;
d2rq:property vocab:persons_FirstName;
d2rq:propertyDefinitionLabel "persons FirstName";
d2rq:column "persons.FirstName";
.
map:persons_LastName a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:persons;
d2rq:property vocab:persons_LastName;
d2rq:propertyDefinitionLabel "persons LastName";
d2rq:column "persons.LastName";
.
map:persons_Address a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:persons;
d2rq:property vocab:persons_Address;
d2rq:propertyDefinitionLabel "persons Address";
d2rq:column "persons.Address";
.
map:persons_Email a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:persons;
d2rq:property vocab:persons_Email;
d2rq:propertyDefinitionLabel "persons Email";
d2rq:column "persons.Email";
.
map:persons_Homepage a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:persons;
d2rq:property vocab:persons_Homepage;
d2rq:propertyDefinitionLabel "persons Homepage";
d2rq:column "persons.Homepage";
.
map:persons_Phone a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:persons;
d2rq:property vocab:persons_Phone;
d2rq:propertyDefinitionLabel "persons Phone";
d2rq:column "persons.Phone";
.
map:persons_URI a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:persons;
d2rq:property vocab:persons_URI;
d2rq:propertyDefinitionLabel "persons URI";
d2rq:column "persons.URI";
.
map:persons_Photo a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:persons;
d2rq:property vocab:persons_Photo;
d2rq:propertyDefinitionLabel "persons Photo";
d2rq:column "persons.Photo";
.
# Table rel_paper_topic
map:rel_paper_topic a d2rq:ClassMap;
d2rq:dataStorage map:database;
d2rq:uriPattern "rel_paper_topic/@@rel_paper_topic.PaperID@@/@@rel_paper_topic.TopicID@@";
d2rq:class vocab:rel_paper_topic;
d2rq:classDefinitionLabel "rel_paper_topic";
.
map:rel_paper_topic__label a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:rel_paper_topic;
d2rq:property rdfs:label;
d2rq:pattern "rel_paper_topic #@@rel_paper_topic.PaperID@@/@@rel_paper_topic.TopicID@@";
.
map:rel_paper_topic_RelationType a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:rel_paper_topic;
d2rq:property vocab:rel_paper_topic_RelationType;
d2rq:propertyDefinitionLabel "rel_paper_topic RelationType";
d2rq:column "rel_paper_topic.RelationType";
d2rq:datatype xsd:integer;
.
map:rel_paper_topic_PaperID__ref a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:rel_paper_topic;
d2rq:property vocab:rel_paper_topic_PaperID;
d2rq:refersToClassMap map:papers;
d2rq:join "rel_paper_topic.PaperID => papers.PaperID";
.
map:rel_paper_topic_TopicID__ref a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:rel_paper_topic;
d2rq:property vocab:rel_paper_topic_TopicID;
d2rq:refersToClassMap map:topics;
d2rq:join "rel_paper_topic.TopicID => topics.TopicID";
.
# Table rel_person_organization (n:m)
map:rel_person_organization__link a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:persons;
d2rq:property vocab:rel_person_organization;
d2rq:refersToClassMap map:organizations;
d2rq:join "rel_person_organization.PersonID => persons.PerID";
d2rq:join "rel_person_organization.OrganizationID => organizations.OrgID";
.
# Table rel_person_paper (n:m)
map:rel_person_paper__link a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:papers;
d2rq:property vocab:rel_person_paper;
d2rq:refersToClassMap map:persons;
d2rq:join "rel_person_paper.PaperID => papers.PaperID";
d2rq:join "rel_person_paper.PersonID => persons.PerID";
.
# Table rel_person_topic (n:m)
map:rel_person_topic__link a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:persons;
d2rq:property vocab:rel_person_topic;
d2rq:refersToClassMap map:topics;
d2rq:join "rel_person_topic.PersonID => persons.PerID";
d2rq:join "rel_person_topic.TopicID => topics.TopicID";
.
# Table topics
map:topics a d2rq:ClassMap;
d2rq:dataStorage map:database;
d2rq:uriPattern "topics/@@topics.TopicID@@";
d2rq:class vocab:topics;
d2rq:classDefinitionLabel "topics";
.
map:topics__label a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:topics;
d2rq:property rdfs:label;
d2rq:pattern "topics #@@topics.TopicID@@";
.
map:topics_TopicName a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:topics;
d2rq:property vocab:topics_TopicName;
d2rq:propertyDefinitionLabel "topics TopicName";
d2rq:column "topics.TopicName";
.
map:topics_URI a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:topics;
d2rq:property vocab:topics_URI;
d2rq:propertyDefinitionLabel "topics URI";
d2rq:column "topics.URI";
.
map:topics_ParentID__ref a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:topics;
d2rq:property vocab:topics_ParentID;
d2rq:refersToClassMap map:topics;
d2rq:alias "topics AS topics__alias";
d2rq:join "topics.ParentID => topics__alias.TopicID";
.
参考:
D2RQ: http://d2rq.org/ The D2RQ Mapping Language: http://d2rq.org/d2rq-language neosemantics (n10s): https://github.com/damo894127201/neosemantics