A lightweight simulation of an ODMG-style Object-Oriented Database Management System (OODBMS) featuring direct pointer-overloaded graph navigation, custom vacancy bitmap recycling, and binary persistence.
By bypassing relational impedance mismatch and storing C++ structs directly as binary extents, DataStore delivers blazing query speed and expressive syntax.
Implements the canonical Object Data Management Group trifecta: ODL (Object Definition Language), OCL (Object Creation Language), and OML (Object Manipulation Language).
Traverse deep entity graphs without SQL JOINs. Navigate associations seamlessly using native C++ pointer syntax: pcur.dept->loc->addr->city.
Maintains .v.dat vacancy files using compact bitfield tracking. Deleted records are instantly freed and recycled in O(1) time without fragmentation.
Every entity has an isolated binary extent directory under ./DataStore/. Paired with o.dat offset indices and v.dat vacancy records.
Built-in bag<S> and set<S> template containers manage 1-to-N relationships, membership checks, insertion, and memory caching out of the box.
Seamlessly compiles and runs on both modern Linux (GCC / POSIX filesystem APIs) and Windows (MSVC / Visual Studio 2022 / Win32 console).
Experience DataStore in action right in your browser. Trigger creation, relationship linking, pointer navigation queries, and watch binary records & vacancy bitmaps update in real-time.
* Click on any block to inspect its allocation slot and status in personv.dat / deptmv.dat.
An elegant four-layer design that cleanly separates object definitions, relationship manipulation, container logic, and binary persistence.
Examine the actual implementations of ODL schemas, OCL creation, OML queries, and the core template database engine.
// OML.CPP - Object Manipulation Language & Pointer Graph Navigation
#include "DATABASE.CPP"
#include "ODL.CPP"
int main()
{
clrscr();
// 1. Load persisted records from binary extents
database<address> acur(2); acur.movefirst();
database<location> lcur(2); lcur.movefirst();
database<department> dcur(2); dcur.movefirst();
database<person> pcur(2); pcur.movefirst();
// 2. Link object relationships (Location -> Address)
lcur.addr.addlink(&acur);
lcur.updateit();
// 3. Link Department -> Location
dcur.loc.addlink(&lcur);
dcur.updateit();
// 4. Link Person -> Department
pcur.dept.addlink(&dcur);
pcur.updateit();
// 5. Pointer-overloaded deep traversal query!
if (pcur.dept.operator->() && pcur.dept->loc.operator->())
{
cout << "Navigated Location: " << pcur.dept->loc->name << endl;
}
cout << "\nQuery finished. Press any key..." << endl;
getch();
return 0;
}
// OCL.CPP - Object Creation Language & Binary Extent Allocation
#include "DATABASE.CPP"
#include "ODL.CPP"
int main()
{
clrscr();
// Mode 1 indicates new persistent object instantiation
database<person> perm(1);
perm.add(); // Interactively takes name, employee # and commits
database<department> dept(1);
dept.add();
database<location> loc(1);
loc.add();
database<address> addr(1);
addr.add();
cout << "\nRecords added successfully to ./DataStore/. Press any key...\n";
getch();
return 0;
}
// ODL.CPP - Object Definition Language (ODMG Schemas)
#pragma once
#include "DATABASE.CPP"
class department;
class location;
class address;
class person : public Persistance
{
public:
char name[30];
set<department> dept; // ODMG 1-to-N Relationship
person() {
strcpy(extent, "person");
strcpy(name, " ");
}
void add() {
cout << "Employ Name:";
safe_read_line(name, sizeof(name));
}
friend class database<person>;
};
class department : public Persistance
{
public:
char name[20];
set<location> loc;
department() {
strcpy(extent, "deptm");
strcpy(name, " ");
}
/* ... add() and methods ... */
};
// DATABASE.CPP - Core Engine Template & Vacancy Bitmap Allocation
template <class S>
S *set<S>::operator->()
{
this->link = new S;
if (this->pos >= this->itemcount) {
delete this->link;
return nullptr;
}
database<S> temp(2);
if (this->contents[this->pos] == 0) {
delete this->link;
return nullptr;
}
// Load target entity directly by OID offset
temp.load(this->contents[this->pos]);
*(this->link) = (S)temp;
ptrArray[p_count++] = this->link;
return this->link;
}
// Cross-Platform Directory Initialization
void addfullpath()
{
#ifdef _WIN32
CreateDirectoryA("DataStore", NULL);
#else
mkdir("DataStore", 0777);
#endif
snprintf(fullclassname, sizeof(fullclassname), "./DataStore/%s", ext);
snprintf(file_o, sizeof(file_o), "./DataStore/%so.dat", ext);
snprintf(file_v, sizeof(file_v), "./DataStore/%sv.dat", ext);
}
Tested and optimized for both Linux environments (GCC / Clang / POSIX) and Windows (Visual Studio 2022 / MSVC / CMake).
GCC 9+ / Clang 10+ / Ubuntu, Debian, Fedora, Arch
mkdir("DataStore", 0777)
-O3 optimization
Visual Studio 2022 / MSVC v143 / CMake / Windows 10 & 11
OODBMS.sln with OCL & OML projects
build.bat for MSBuild