The Entity–Attribute–Value (EAV) model is a database design used in applications that require dynamic and flexible data management. This model is particularly advantageous in situations where different entities have different attributes and these attributes are not known in advance.
The Kuika platform supports the EAV model with ready-to-use tables and actions, enabling the system to be expanded without interruption even in a live environment.
Basic Logic of the EAV Model
The EAV model manages data with three components:
- Entity: The object being recorded (e.g., product, customer, patient).
- Attribute: The quality of the entity (e.g. colour, size, battery capacity).
- Value: The value of the attribute (e.g. red, 180 cm, 3600 mAh).
Each Attribute–Value pair is stored as a separate row in the database. For example:
EAV Example Table
EAV Example Table (EN)
Entity |
Attribute |
Value |
Car |
Torque |
420 Nm |
Car |
Horsepower |
350 HP |
Smartphone |
Battery |
3600 mAh |
Smartphone |
Screen Size |
6.1 inch |
Thanks to this structure:
No need to change the table schema to add new features.
- The same attribute can be reused in different entities.
Application Development with EAV Model in Kuika
Kuika offers predefined system tables and actions to support the EAV model. With this structure, users can create dynamic forms and flexible data structures without changing the database schema.
Kuika EAV Data Tables
- KCategory: Categorises Entities and Attributes (e.g. Electronics, Clothing).
- KEntity: Defines entity types (e.g. Phone, Trousers).
- KAttribute: Contains all potential properties (e.g. Colour, Battery Capacity).
- KEntityAttributeMap: Maps Attributes to Entities.
- KEntityValue: Stores entity instances (e.g. iPhone 13).
- KEntityAttributeValue: Stores the attribute values of each entity instance.
Data Flow Process
- Entity Creation:
- Define a new entity with the Create Entity action.
- For example, phones or trousers.
- Attribute Definition:
- Create properties using the Create Attribute action.
- For example, Screen Size or Inseam Length.
- Specify the data type (String, Integer, Boolean).
- Entity and Attribute Mapping:
- Map attributes to the relevant entities using the Entity Attribute Map action.
- For example, Battery Capacity can only be mapped to the Phone entity.
- Dynamic Form Usage:
- With the Dynamic Form component, all attributes associated with an entity are automatically listed as form fields.
- The appropriate input type (date picker, number field, etc.) is displayed based on the data type.
- Data Saving:
- Example: Screen Size: 6.1 inches, Battery: 3600 mAh.
- Data Reading and Updating:
- View records with the Get Entity Values or Get Entity Attribute Values actions.
- Update values with Set Entity Attribute Value.
- Existing data can be automatically filled in when the form is opened with Get/Set Entity Value in Dynamic Form.
Use Cases
- E-Commerce Applications: Fields specific to products (e.g. Size for shoes, Battery Capacity for phones).
- Application Forms: Dynamic fields that vary depending on the user.
- Catalogue Management: Flexible structure with fields specific to different product categories.
Things to Consider
- The EAV structure is in beta.
- Comprehensive testing should be performed for data consistency and functionality before using it in a live environment.
- Users can add new entities and attributes without interruption, but performance should be monitored after these operations.
Thanks to Kuika's EAV support:
- Data management can be performed without a fixed schema.
- New entities and attributes can be added via the user interface.
- The application can be extended without interrupting the live environment.
This approach makes Kuika a powerful and sustainable solution for dynamic data models. Once you have learned the basic structure of the EAV model, you can start developing your application using EAV actions on the Kuika platform.
For more information, check out the Getting Started with EAV Actions section.
In this section, you can find details on how to use Attribute, Category, Entity, Dynamic Form, and other EAV actions in Kuika.