Sprout is a project dedicated to an object-oriented programming language that is native to the Relational Database Management System (RDBMS). It is not an object-relational mapping solution or an add-on language but an entirely new database language backward-compatible with the existing SQL syntax. By extending RDBMS procedural language available with Persistent Stored Module (SQL/PSM) standard it delivers vernacular database object-oriented programming language.
Sprout programming language instructions in their low level format are composed of nested key-value pairs. The pairs are stored in normalized form inside a registry implemented with Entity Attribute Value data model. The registry can also store table columns and sets of single node values that constitute documents of any structure like program code, HTML, XML, RDF, etc.
Procedural vs. Object-Oriented.
Procedural languages native to many RDBMS platforms make available limited object-oriented features like classes, their instances and inheritance. Sprout, while written with a standard SQL/PSM, addresses that limitation by introducing call stack and memory addressing routines that enable features attributed to object-oriented programming.
In the example below there are three program functions: a() with one command before and after invocation of b() with two commands before and after invocation of c() with three commands in total:
In a procedural language the call stack is ordered in the sequence of commands made of all nested invocations from beginning to end:
Result of a function invocation is optionally assigned to a value. To do so the language executes code of the invoked function and assigns the result to a variable. For example in function a():
DECLARE B; B = b();
In an object-oriented language the call stack control routine makes hops over the stack structure. One location in the stack may contain a pointer to another location or address. This feature makes possible creating instances of classes – an
important feature in the object-oriented programming paradigm.
Creating reference pointers to a call stack address may be advantageous over assigning a variable to the result of invocation. For example the caller does not need to be aware of class type to create its instance, methods are associated with a class, inheritance and others. Instantiate a class by creating reference to class header in the call stack in function a():
B = NEW b();
Database objects (tables, views) are accessible with their resource identifiers with each assigned a unique numeric identifier in the registry. For example a table structure is defined in a document of an application user in a domain.
SELECT * FROM <domain>.<application>.<user>.<document>.<table> ; SELECT * FROM table(<unique identifier>) ;
In another example there is a class user() with methods list(), update():
-- select all users SELECT * from user.list(); -- select user with id 1 SELECT * from user.list(1); -- update user with id 1 U = NEW user(); U.Name = 'Joe'; U.DOB = '1/1/2000'; SELECT U.update(1);
- Object oriented programming language native to RDBMS
- Column and row level restrictions on data access
- Entities, rows, and values have unique identifiers
- Referencing of entities, rows, values by URI or numeric identifier
- Variables, arrays, flow-control
- Class instances, instant methods, inheritance
- Complex types for input and output
- Nested key-value pair (low level) code enables high level syntax-independence
- EAV objects do not require physical design
- Executes programs under one database transaction
- Contains at most one “null” per datatype in the registry
- Applies table partitioning and server clustering
Sprout may find use in the following fields:
- Semantic Web
- Sparse data
- Clinical research
- Applications with dynamically changing data model
- Reports, GUI
- Web and other programming
Proof of concept prototype has been built and tested. Long term goal is developing a versatile database visualization platform. Updates of ongoing development will be posted. Source code Github repo is coming soon. The project needs a sponsor.