Example
Take the Notepad application as an example. This application supports data access through browsers and mobile clients. The following is a table design in reference to a relational database:
CREATE TABLE note (
userId VARCHAR(64) NOT NULL,
noteId INT8 NOT NULL, -- increment ID
title VARCHAR(256),
content VARCHAR(2048),
version INT,
mtime BIGINT,
category VARCHAR(16),
PRIMARY KEY(userId, noteId),
INDEX(userId, mtime), -- change time index
INDEX(userId, category) -- category index
);
Assuming the application has 4 access modes:
According to noteId, query on a note for detailed information
Save details of a note according to noteId (conditions can be written to version to check for concurrent modifications)
Based on modification time of the note to scan paging for query. Only title is shown. User can click to view further details of the note
Query based on the category label of the notes
Table definition
For this application, it can be converted into the table definitions of SDS:
- Entity group key - userId*, for starting hash distribution
- Primary Key - noteId, reverse coding
- Time modification index - mtime, reverse encoding, eager type index. Projection of title and noteId
- Category index - category, lazy* Type index
This guide's API will use this table as a standard example for elaboration.