Extension attributes are never stored in separate columns, in contrast to regular attributes. They are stored in one big JSON object which is saved in one column. Thus you can extend your tables, without changing their structure in the database. To make your Data Motel extendable, do the following steps:
Step 1. Creating extension container column in the database
You need to create a column to store all extension attributes in the table that you're planning to extend. We recommend to use the following data types for different DBMS:
- for MSSQL - nvarchar(max)
- for Postgres - text
- for Oracle - CLOB
Step 2. Adding extension container attribute into DataModel
Now you need to add created attribute into the data model and specify its name in the data model Extensions container property. You can add attribute manually, or using database synchronization with model.
Step 3. Creating extension attributes
Next, to create necessary extension attributes, you just need to add them into the data model and mark them as Extension. You don't have to add columns into the table in the database. Please, note that you can create both extension attributes-columns and extension attributes-references.
See example of extension attributes usage in DWKit HRM project. There is one table to store all types of documents in this system - Document. But there are data models for each document type, and all additional attributes in them are extension attributes. Here are these Data Models:Business trip, Compensation, Recruitment and Vacation. Pay attention to extension attributes in these models.