amacks
amacks

Reputation: 80

Term for SQL table design?

I've seen this design paradigm a couple of places, often when storing somewhat unpredictable data (custom user preferences, that sort of thing), where the table has only 4 columns:

row_id - unique
item_id  - indexed, userid or whatever "owns" the preference
name - name of the field
value - field value

So it's basically unstructured data stored in SQL. Is there a term for this style of table? It might be the right way to solve a problem I'm having, but I don't want to use it without more research, and it's hard to research without a name

Upvotes: 1

Views: 56

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1270873

This is called an entity-attribute-value model (EAV). Wikipedia (of course) is a good place to start.

There are some limitations when using EAV in a relational database. In particular, the types of the values tend to be strings, regardless of the natural type. In addition, foreign key relationships can be difficult to express in some databases.

Upvotes: 6

Related Questions