JavaScript Entity Table Model
Let’s learn how to make a JavaScript entity table model.
We'll cover the following
Make a JS entity table model
Since we use the browser’s local storage as the persistent storage technology for our example application, we need to deal with simple key-value storage. For each design model class that has a singular and capitalized name (for example, Entity
), we use its pluralized lowercase name (entities
) as the corresponding table name. We also use it as a key. Its associated string value is obtained if we serialize the object collection method Entity.instances
with the help of the JSON.stringify
method.
We design a set of suitable JS entity tables in the form of a JS entity table model that we derive from the information design model. We need to make certain choices about how to organize our data store and how to derive a corresponding entity table model.
Our first choice to make concerns if we need to use the Single Table Inheritance (STI), the Table per Class Inheritance (TCI), or the Joined Tables Inheritance (JTI) approach.
In the Single Table Inheritance approach, a segmentation, or an entire class hierarchy, is represented with a single table. This table contains columns for all attributes of all classes involved, as shown in the example model below:
Get hands-on with 1400+ tech skills courses.