Simulating column variable names in sqlite

I want to store records (a set of key => value pairs) in the database, but the keys change from record to record.

I was thinking of storing with two tables, (1) the keys for each record and (2) the values ​​of specific keys for each record, where the records have a common id field in both tables, but I'm not sure how to pull records as key => value pairs in sql with this configuration.

Is there a better way? If this is not possible in sqlite, is this possible in mysql? Thank!

+3
source share
2 answers

It looks like you are looking for a model of an attribute-value-object .

- NULL , .

, Bill Karwin SQL Antipatterns EAV . 16.

+4

@Mark Byers , EAV. Bad CaRMa, . , .

. . SQLite, MySQL .

. - SQL SQL Antipatterns, , EAV.

, . - , CouchDB MongoDB, .

Berkeley DB, SQLite.

+1

Source: https://habr.com/ru/post/1750737/


All Articles