Download presentation
Presentation is loading. Please wait.
1
odb A short visit Object Database in C++
2
Problems to address What is the odb good for
3
Problems to address Mainly empty data tables
Most tables in Relational Databases are empty because they preserve space for fields which may receive data
4
Problems to address Mainly empty data tables
Intermediate data structures to build relations To establish links between data elements, additional data elements must be used, not representing data but links. Links are of a different nature than data but while relational databases are named relational, they do not incorporate relations in their design.
5
Problems to address Mainly empty data tables
Intermediate data structures to build relations Static data- and relation models Relational database structures have to be designed and implemented to become able to store certain data and relations. Changes are not simple to make, in most practical applications can't be done at all. Users do not have any influence over the data model. If e.g. some DB application is missing a specific data field (may be a 4th name), this information gets lost if it exists but the DB model designer did not provide such field.
6
Solution odb tries to address those problems with simple answers.
7
Solution No tables If most tables in databases are almost empty, why use tables? odb only stores data, not non-data / potential data
8
Solution No tables No relational information as data (terry&gaspode, what is the relational data?) Relations are information, but not data. Data is e.g. „name=Pratchett“ and „dog=Gaspode“ but the relation between the men called „Pratchett“ and the dog called „Gaspode“ is characterized by the reason the relationship is made for. So data for such relationship is „Terry Pratchett“ relates to „Gaspode“ by „has written about“. So the data related to data relations is the reason for said relation. This information is not stored in relational databases. In contrast odb stores reasons within links.
9
Solution No tables No relational information as data No data models
odb doesn't support the design of predefined data models. The application using odb defines the interface to the data stored in the odb. odb itself does not support data structures.
10
odb A short introduction
The following presentation will try to a little bit deeper into the design of the odb. A short introduction
11
odb Using classes of ´things´ to store
odb is using different classes of things to store data in a meaningful, a semantic way
12
odb Using classes of ´things´ to store Objects of types/classes
Objects are complex ´things´. In our physical macro cosmos a person may count as an Object. So one may store „Terry Pratchett“ as Object of class „Person“ as well as „Lyn Pratchett“ of the same class. Or one may store „The color of magic“ of class „Novel“
13
odb Using classes of ´things´ to store Objects of types/classes
Reasons to link Objects „Terry Pratechtt“ had of course a relation to „Lyn Pratchett“ by being „married“ to here and to „The color of magic“ by being the „Author“ of it.
14
odb Using classes of ´things´ to store Objects of types/classes
Reasons to link Objects Atoms (or attributes) Atoms store attributes for Objects, Objects may link to Objects, and contain Atoms. So for an Object of class „Person“ named „Terry Pratchett“ an Atom may be „profession=Author“. Objects may link (with no Reason) to an infinite amount of Atoms and (with Reason) to an infinite amount of Objects
15
odb Using classes of ´things´ to store Objects of types/classes
Reasons to link Objects Atoms (Ropes of Atoms) One possibly premature optimization (and specialization) was the introduction of Ropes which store chains of Atoms in a single Atom linkage. I only name this construct for people who visit the code so that they understand what Ropes are for.
16
odb - Linking Objects Now, how to link one object to another one?
17
odb - Linking Objects Objects, by nature, are having relations.
All objects of the world are having relations, some sense full, some senseless.
18
odb - Linking Objects Objects, by nature, are having relations. For example „Terry“ „is married to“ „Lyn“ „Terry Pratchtt“ may be linked to „Lyn“ for the reason „is married to“.
19
odb - Linking Objects Objects, by nature, are having relations. For example „Terry“ „is married to“ „Lyn“ „Terry“ „is married to“ „The color of Magic“ But amazingly „Terry Pratchett“ should not be linked to „The color of Magic“ for the same reason („is married to“)
20
odb - Linking Objects Objects, by nature, are having relations. For example „Terry“ „is married to“ „Lyn“ „Terry“ „is married to“ „The color of Magic“ odb should solve this problem by design. To solve this problem, one should become aware about another problem. Whilst „Terry“ „is married to“ „Lyn“, as humans know also means „Lyn“ „is married to“ „Terry“
21
odb - Linking Objects Objects, by nature, are having relations. For example „Terry“ „is married to“ „Lyn“ „Lyn“ „is married to“ „Terry“ The same can´t be said about „Terry“ and „The color of Magic“
22
odb - Linking Objects Objects, by nature, are having relations. For example „Terry“ „is married to“ „Lyn“ „Lyn“ „is married to“ „Terry“ „Terry“ „is author of“ „The color of Magic“ Whilst „Terry“ „is author of“ „The color of Magic“
23
odb - Linking Objects Objects, by nature, are having relations. For example „Terry“ „is married to“ „Lyn“ „Lyn“ „is married to“ „Terry“ „Terry“ „is author of“ „The color of Magic“ „The color of Magic“ „is author of“ „Terry“ The sam can’t be true vice versa. Which means, links are unidirectional
24
odb - Linking Objects Objects, by nature, are having relations. For example „Terry“ > „is married to“ > „Lyn“ „Terry“ > „is author of“ > „The color of Magic“ If Reasons are unidirectional they should be forceable to link Objects only by possible class relationships. „is married to“ is allowed to link „Person“ Objects to other „Person“ Objects whilst „is author of“ is suitable to link „Person“ Objects to „Novel“ Objects. This enables to establish all feasible links
25
odb - Linking Objects Objects, by nature, are having relations. For example „Terry“ > „is married to“ > „Lyn“ „Lyn“ > „is married to“ > „Terry“ „Terry“ > „is author of“ > „The color of Magic“ The relation „The color of Magic“ „is author of“ „Terry“ is not assignable because there is no matching Reason in the database.
26
odb - Linking Objects Reasons are used to Link Objects to Objects
To link objects to objects Reasons are necessary
27
odb - Linking Objects Reasons are used to Link Objects to Objects
Optionally enforcing Class Relationship Reasons may (and should) be given Classes to determine which kind of Objects the specific Reason is suitable to link. So it’s possible to force Reasons to specific classes of Object on one or both ends („id owner of“ may link a „Person“ Object to every other Class of Objects by linking from „Person“ to NULL
28
odb - Linking Objects Reasons are used to Link Objects to Objects
Optionally enforcing Class Relationship, e.g. 'is married to' links from Person to Person For example the Reason ‚is married to‘ is suitable to link an Object of Class ‚Person‘ to an Object of Class ‚Person‘. It is the property of an Object to be linked to another Object.
29
odb - Linking Objects Reasons are used to Link Objects to Objects
Optionally enforcing Class Relationship, e.g. 'is married to' links from Person to Person, or ‚is owner of‘ links from Person to ??? „is owner of“ is allowed to link a „Person“ Object to all other classes of Objects.
30
odb - Linking Objects Reasons are used to Link Objects to Objects
Optionally enforcing Class Relationship, e.g. 'is married to' links from Person to Person, or ‚is owner of‘ links from Person to ??? Reason("is owner of“, classPerson, nullptr) The instantiation of a Reason may look like this: „Reason Name“, „Class to link from“, „Class to link to“
31
odb - Linking Objects Class 'Person' Reason 'is married to' Class
So there may exist a Reason named „is married to“ which is allowed to link a Person to a Person. Class 'Person' Reason 'is married to' Class 'Person'
32
odb - Linking Objects Object "Terry" of Class 'Person' Object "Lyn"
And there may exist two Objects of Class Person Object "Terry" of Class 'Person' Object "Lyn" of Class 'Person'
33
odb - Linking Objects Class 'Person' Class 'Person' Object "Terry"
So this Reason can be used to link those Objects. Remember, the link from the first object to the second one is the property of the first object. Now it may be interesting for the second Object to „know“ which Objects do have links to it. Object "Terry" of Class 'Person' Reason 'is married to' Object "Lyn" of Class 'Person'
34
odb - Linking Objects Class 'Person' Class 'Person' Object "Terry"
Therefor the creation of a link from one Object to another one adds an unnamed Backlink entry to the properties of the second Object. Such Backlinks are only Backlinks without Reason information and only exists once, even if the first Object links multiple times (with different Reasons) to the second one. Object "Terry" of Class 'Person' Reason 'is married to' Object "Lyn" of Class 'Person' Unnamed backlink
35
odb - Linking Objects Class 'Person' Class 'Novel' Object "Terry"
Another Reason to link two Objects may be setup as „is author of“, linking a Person to a Novel. Object "Terry" of Class 'Person' Reason 'is author of' Object „The …“ of Class 'Novel' Unnamed backlink
36
odb - Linking Objects Reason 'is married to' Object "Lyn"
Object "Terry" of Class 'Person' Reason 'is married to' Object "Lyn" of Class 'Person' Unnamed backlink So „Terry“ has two links to different Objects, those Objects are having Backlinks to „Terry“. AND: The used Reasons store Links to the „Terry“ Object instance. Object "Terry" of Class 'Person' Reason 'is author of' Object „The …“ of Class 'Novel' Unnamed backlink
37
odb - Linking Objects A linking Object stores Links with Reasons
One entry per Reasons Objects store Reasons for Links to link to Objects
38
odb - Linking Objects A linking Object stores Links with Reasons
One entry per Reasons A linked Object stores Links to linking Objects without Reason, one entry per linking Object Objects store Backlinks to linking Objects
39
odb - Linking Objects A linking Object stores Links with Reasons
One entry per Reasons A linked Object stores Links to linking Objects without Reason, one entry per linking Object A Reason stores Objects it links from One entry per Object Reasons store Objects they are used by
40
odb - Query Objects How to Query linked and linking Objects
41
odb - Query Objects Ask Objects Where they link to
For what reasons they link to An Object may be asked to which Objects they are linking to and for which Reason
42
odb - Query Objects Ask Objects From whom they are linked to
Query linking Objects for the Reason they link Objects may be asked which Objects are linking to them. If one needs to know the Reason(s) the linking Object has to be asked.
43
odb - Query Objects Ask Reasons Which Objects are using them
Ask Objects for their Link Destinations Reasons may be asked which Objects they are used by. Reason using Objects may be asked for the Objects they are linking to for a specific Reason.
44
odb - Query Objects Ask Atoms Which Objects are using them
Ask Objects for their lists of Atoms Reasons may be asked which Objects they are used by. Reason using Objects may be asked for the Objects they are linking to for a specific Reason.
45
odb - Atoms A short view to ‚conventional' data storing in odb
46
odb - Atoms Used to „store data“ in the sense of Databases
are Applicable data fields for Objects Objects may hold an unlimited amount of Atom References
47
odb - Atoms Used to „store data“ in the sense of Databases
are Applicable data fields for Objects are Shareable between Objects Atoms may be used by an unlimited amount of Objects
48
odb - Atoms Used to „store data“ in the sense of Databases
are Applicable data fields for Objects are Shareable between Objects are Collectalbe in Ropes Ropes collect „mass Atom collections“ using one single connection to the object they are used.
49
odb - Atoms Used to „store data“ in the sense of Databases
are Applicable data fields for Objects are Shareable between Objects are Collectalbe in Ropes know who uses them Atoms know who are using them.
50
odb - Templates For practical reasons odb supports a kind of ‚thing‘-templating
51
odb - Templates An example Object: Class „Person“ Atom Name = „Lyn“
Atom Gender = „Female“ Atom Profession = „Lector“ If an application provides a GUI to odb data and the GUI depends on the fields stored in the object, that's to say the GUI is as dynamic as the database, it would be not a nice GUI if each data field had to be defined by the user each an every time. Then you would have to follow these steps „define new field“, „input the name for the field“, „input the content for the field“. This would be a most tedious experience. That´s why odb provides a template mechanism.
52
odb - Templates An example Object: Class „Person“ Atom Name = „Terry“
Atom Gender = „Male“ Atom Profession = „Author“ A second, similar Object assigned to the same Class may be instantiated
53
odb - Templates An example Object Master Atom List (OMAL):
Class „Person“ Atom Name = „“ Atom Gender = „“ Atom Profession = „“ An Object Master Atom List (OMAL) is a template that provides a predefined Class for the Object and a list of suggested Atoms suitable to the Object. The final „Person“ Object may then look like this:
54
odb - Templates An example Object using an OMAL: OMAL „PERSON“
Atom Name = „Terry“ Atom Profession = „Author“ The Object will be assigned to the Atoms filled in with data and none of the template Atoms if not given.
55
odb - Templates An example Object using an OMAL: OMAL „PERSON“
Class „Person“ Atom Name = „Terry“ Atom Gender = „“ Atom Profession = „Author“ Empty Atoms can be presented by a GUI provided as place holders for data input but if not used, will not be stored.
56
odb - Templates Some example Atoms: „title“ = „The color of Magic“
„pagecount" = „256“ „Pages“ „price“ = „CHF“ „14.90“ This can be realized directly or by use of Atom template objects, called Atom Definition Objects (ADO)
57
odb - Templates Atom attributes besides ´data´: name prefix format
suffix An Atom, and so an ADO (because an ADO is an Atom) supports additional elements like prefix and suffix and also format strings to output its data element
58
odb - Templates ADO: „pagecount" = „256“ „Pages“ name = „pagecount“
prefix = „“ format = „%d %s“ suffix = „Pages“ No prefix given
59
odb - Templates ADO: „price" = „CHF“ „14.90“ name = „price“
prefix = „CHF“ format = „%s %.2f“ suffix = „“ No suffix given
60
https://github.com/morgner/odb
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.