-
Notifications
You must be signed in to change notification settings - Fork 0
Implicit database constraints
Note: This functionality is not released yet, and not in the develop branch
Primary and foreign keys are of paramount importance for ontop to generate fast sql. The lack of primary keys can lead to "self-joins" which may render the sql queries impossible to execute in the given constraints of memory and time. The best solution to this is usually to have primary keys in all tables and add all foreign keys. In some situations this may not be possible. Acknowledging these issues, ontop allows the user to supply a list of primary and foreign keys in the initialization of quest.
Although these keys are not in the metadata of the database, these must of course still be correct primary and foreign keys, in the abstract sense: primary keys must be unique and non-null, and foreign keys must refer to existing values in a key column. Ontop does not check that the user-provided keys are correct. The correctness of the algorithms behind ontop depends on only correct keys being provided. Wrong keys may lead to wrong and lacking answers to queries. If you are unsure whether column c
in table t
is a key, compare the answers to select count(*) from t
and select count(distinct c) from t
.
The keys are listed in a plain-text file. Each line describes a primary or foreign key. Lines describing a primary key starts with the table name, a colon, and then a comma-separated list of the columns in the key. The lines describing foreign keys start the same way as primary keys, and then after a colon, the target of the constraint is described in the same colon- and comma-separated way. An example:
TABLE1:COL1
TABLE1:COL2,COL3:TABLE2:COL1:COL2
COL1 is a key of TABLE1, while COL2 and COL3 are a combined foreign key referring to COL1 and COL2 of TABLE 2.
The name of such a text file is given as input to the constructor of UserConstraints
. The resulting object is passed to the method setUserConstraints
of the QuestOWLFactory. And thats all.
For example, assuming factory
is an initialized object of type QuestOWLFactory
:
ImplicitDBConstraints constr = new ImplicitDBConstraints(<name of file containing user-supplied constraints>);
factory.setImplicitDBConstraints(constr);
For use with SeseameVirtualRepo, just pass the ImplicitDBConstraints
object to the method setImplicitDBConstraints
method before calling initialize
, for example:
`SesameVirtualRepo repo = new SesameVirtualRepo(repoName, owlfile, r2rmlFile, configFile);
ImplicitDBConstraints constr = new ImplicitDBConstraints(<name of file containing user-supplied constraints>);
repo.setImplicitDBConstraints(constr);
repo.initialize();
repo.getQuestConnection()
- Quick Start Guide
- Easy-Tutorials
- More Tutorials
- Examples
- FAQ
- Using Ontop
- Learning more
- Troubleshooting
- Developer Guides
- Links