How it works
/db takes an existing database model and automatically constructs a web service API from it. This makes your data instantly accessible to mobile applications, websites or enterprise systems.
/db works in two modes:
- Data Discovery – automatically reflects all objects in database as URL addressable resources
- SQL Pass-thru – configure any SQL statement and map it to a URL
In both modes data becomes addressable via simple URL.
Data Discovery Mode
In this mode all records automatically become HTTP resources, which can be read and udpated.
For example an individual Customer’s record in the Chinook database would be referenced like so:
/db effectively constructs a graph representation of all relational databases behind it. The system reflects the data model’s relationships, so links between related records are natural to follow.
For example, customer’s invoices can be referenced as:
or from the side of the Invoice table like this:
Drill-downs to vector slices and individual scalar values are also supported without sacrificing clarity of the URL link.
Customer’s name by itself, represented in XML can be reached using this URL:
Customers first name, last name and phone number:
In-lining related records within a document of a parent record is another powerful mechanism that simply works out of the box. In a single request you can get a Customer record with all his/her Invoice records.
There are plenty more powerful features in Data Discovery, but sometimes you may want or need to run an SQL query or a stored procedure. The next section in about that.
SQL Pass-thru Mode
Using this mode SlashDB administrator or a application backend developer can define arbitrary SQL queries using SlashDB configuration GUI. Once defined, those queries can be executed using a URL. For example this query returns customers from London:
As before the results are available in all supported formats simply by changing the extension of the URL:
Queries can be fully parameterized. In fact to get customers from another city user would simply substitute that part of the URL: