Introduction
The use-cases and requirements for this design are outlined in Records and RecordStores. This document will describe the proposed model object, REST APIs, and usage patterns of a new Synapse object called a TableEntity.
A TableEntity is a new Entity type that has many of the attributes of a relational database table. In fact, we will adopt all of the nomenclature from: http://en.wikipedia.org/wiki/Relational_database.
Object Model
The following class diagram shows how TableEntity integrates with the rest of the Entity model objects:
The TableEntity is a model object that describes the table including the columns and any constraints. The TableEntity model object does not encapsulate any row data. Instead, a separate services will be provided to add, update, delete, fetch and query rows from a table entity. A TableEntity can have an ACL like all other Synapse Entities that can be used to restrict access to the table and all of its rows. We are not planning to support row level authorization at this time.
REST API
URL | Method | Request Body | Response Body | Description | Authority |
---|---|---|---|---|---|
/entity | POST | TableEntity | TableEntity | Create a new TableEntity as you would any other Entity in Synapse. A new TableEntity will not have any rows. Add rows see POST /table/<id> | Must have the CREATE permission on the parent entity of the table. |
/entity/<id> | GET | TableEntity | Get a TableEntity as you would any other Entity in Synapse | Must have READ permission on the Entity | |
/entity/<id> | PUT | TableEntity | TableEntity | Update the TableEntity. | Must have UPDATE permission on the Entity |
/entity<id> | DELETE | Delete a TableEntity and all of its rows. | Must have DELETE permission on the Entity | ||
/entity/<id>/table | POST | TableUpdateRequest | TableUpdateResponse | This method is used to both add and update rows to a TableEntity. The <id> must be the ID of the TableEntity. The passed TableUpdateRequest will contain all data for the rows to add or update. The TableUpdateRequest.rows is an array of objects, one of each row to add or update. If the RowUpdateRequst.rowId is null, then a row will be added for that request, if a rowId is provided then the row with that ID will be updated (a 400 will be returned if a row ID is provided that does not actually exist). The rowUpdateRequest.values array should contain a value for each column of the row. The TableUpdateReuqest.columns identifies the columns (by name) that are to be updated by this request. Each RowUpdateRequest.value must be the same size as the TableUpdateReuqest.columns as each value is mapped to a column by the index of these two arrays. | Must have UPDATE permission on the TableEntity identified by the <id> |
/entity/<id>/table | DELETE | RowDeleteRequest | Delete all rows identified in the request. | Must have DELETE permission on the Entity | |
/entity/<id>/table?query="<sql like queryr>" | GET | Query the rows of a table with a "SQL like" query string. For example: "select * from <table_id> where foo=bar limit 100 offset 0" | Must have READ permission on the table. |