Data Model Editing
You can find Data Model editing interface in the Data/Manage data model section in the admin panel.
Tutorial
Watch this video to learn how to work with Data Models.
Data Model editing interface
This is Data Model editing interface:
Its control elements have the following functions:
- Reference to all Data Models in the system.
- Name of the opened Data Model.
- Save button.
- Cancel changes button.
- Name - Data Model name.
- DB Object - table or view name in database.
- Scheme name - database (table belongs to) scheme name. It's a non-required field. If it's left empty, default scheme will be used (depends on current DBMS).
- Primary key - attribute name which is primary key. DWKit allows you to work with models without primary keys, but data and form mapping options will be limited in this case.
- Extensions container - attribute name in which other attributes marked as Extension are located. Learn more about Extension attributes here.
- Allows you to switch view mode for extension attributes only.
- Adding a new attribute into Data Model button.
- Name - attribute name. If it's not an extension attribute, this name must strictly match column name in database. If it's an extension attribute, it can be any name.
- Nullable - if checked, attribute value can be NULL.
- Calculated - if checked, attribute value will be calculated in the database (it can be identity columns or calculated columns). DWKit does not allow to update and insert such attributes, but it selects them from database.
- Extension - if checked, attribute will not be stored in a separate column. It will be stored in a JSON object, which in turn is stored in the column which name is set in Extensions container. Learn more about Extension attributes here.
- Type = Column - it's a regular attribute column with data. Data type is set by Data type property in column.
- Data type - data type in attribute column. Note, that it's .NET data type, and not DBMS data type.
- Type = Reference - this is an attribute reference to another Data model. You can select Data Model to which edited data model refers to on the Referenced entity property. This attribute data type will be the same as data type of the primary key of the model selected in the Referenced entity property. In other words it's a foreign key.
- Referenced entity - data model to which edited data model refers to.
- Button to delete attribute from model.
Data model and database mapping
- Each data model is mapped to only one table or view. This table or view name is set in the DB Object property.
- Multiple keys are not supported, that is why you can specify only one attribute value in the Primary key property.
- If attribute is not marked as Extension (i.e. it is not an extension attribute), it is equivalent to a column in the database, that is why its Name must match column name.
- If you've got an attribute reference (i.e. Type = Reference), it is not necessary to create a relevant foreign key in the database.
- To create identity primary key mark relevant attribute of the primary key as Calculated.
- If you've got an attribute reference (i.e. Type = Reference), DWKit must build requests with join to receive column values from the Data
Model edited Data Model refers to. The following simple rule applies by default:
- If attribute reference is nullable, OUTER JOIN is used.
- If attribute reference is not nullable, INNER JOIN is used.