Skip to content

Object Orientated Database (Static Schema)

Since object-oriented databases are an evolution of Relational table DMBS, it is best to understand RDMBSs before you try to understand OODBs.

Structures

An OODB schema can be broken down into different sub-sections called structures.
Each structure is like a description of a tuple. It describes the name of each attribute as well as it's data type.

For instance, you can describe the structure of a database of which stores GPS locations like so;

GPS {
  latt: float32,
  long: float32,
  alt: float32
}

root {
  locations: gps[]
}

You can see that within locations you can store the individual locations the same as you would a tuple within a table. However, the interesting problem is how you handle having more than one unset length array. How can each of them infinitely expand without colliding with each other?

N-Length Arrays

The simplest way is to chunk the array.
In this case, we will pick a chunk size of 50. This means that when the array is initiated it will allocate 50 × GPS.size + 8 bytes.
This means that the array now has 50 empty slots to fill, once these slots are filled, you can then use the last 6 bytes as a direct pointer to the start of another chunk.
Thus, you can continuously expand your array without conflicting with any other arrays.

It can be beneficial to add structure set chunk sizes. For instance if you have an array with a list of all accounts on a website, then you should have your default chunk size quite large to have fewer pointers, However if those accounts then have their own array, i.e. friends, they do not need their chunk size to be so big, since it would be a waste to have massive chunks for only a few items. Personally I prefer the syntax for such arrays to be like this arr[~chunksize]

Pointer

This allows you to directly reference other data. This is done by storing the exact byte index of where the target starts, as well as what data type is there so that it can be read properly.

It is recommended to state that something is a reference via having a leading &, since that follows on the pre-existing standards created by C

This example shows how you can have a list of people, and reference all their friends so that you can read their data easily.

person: {
  given: string[15],
  family: string[15],
  street: string[30],
  suburb: string[10],
  state: string[4],
  friends: &person[~5]
}

root{
  people: person[~50]
}