Metadata database model
Instead of creating 100 columns in a table for data that might or might not exist, we use another table called xMetadata (replacing x with a model name).
Columns
| Name | Type | Default value | Constraints & Validations |
|---|---|---|---|
| id | Integer (unsigned) | PRIMARY KEY AUTO_INCREMENT |
|
| key | String | NOT NULL | |
| value | LongText | null | NULL |
| valueType | String | 'NULL' | NOT NULL |
| foreign_key | String | Integer (unsigned) | NOT NULL (linked to id of non-metadata model/table) |
All data can be stored under keys. The type of keys that are used depends on the model.