GraphDB
4. GraphDB
We use GraphDB to store majority of the data. GraphDB is a triplestore database supports RDF and SPARQL, the detail is here
The servers connects to GraphDB repository cmmp via localhost:7200, and cmmpTest for test environment
4.1 GraphDB Dashboard
GraphDB provides user interface dashboard for manage database repository, the related documentation is here.
4.2 Loader/Settings
4.2.1 Preload NPM packages
First preloading the related NPM packages and utils setting. The extra packages required are graphdb, fs, node-fetch and form-data
4.2.2 GraphDB Repository
Then you can create GraphDB Repository by the following and import RDF4J configuration
Also, you need to have a function to get the repository, which needed for load function later on
4.2.3 Load Data
Then, we can load the RDF data to the graphDB.
Note: overwrite is set to True when you want to reset the GraphDB data, by default, we always reset data
when run the test in test environment.
4.2.4 Load GraphDB
After the preparation of packages, function of configurations, repositories and load data, we can load the whole GraphDB module in the loader
Note: The namespace is for convenience to build up SPARQL query without duplication.
4.3 SPARQL, RDF, and Ontologies
4.3.1 RDF
Resource Description Framework. You can read details here
4.3.2 SPARQL
SPARQL is a powerful query language. You can read details here
4.3.3 Ontology
The description of ontology can refer to here
4.4 GraphDB Utils
We develop a tool by an object oriented way which can create GraphDB model and manipulate more conveniently. It create and execute the SPARQL query internally.
4.4.1 Create a Model
You can create a GraphDBModel from the functionality of utils/graphDB/graphDBSchema.js
4.4.2 Add new data in GraphDB
Then you can get the SPARQL Query in the following:
4.4.3 Search Data
You can the function with related SPARQL query in the following, respectively
Find all of the primary contact
SPARQL:
Find all of the primary contact matches the first name Test
SPARQL:
Find one primary contact matches the email testuser@example.com
SPARQL: