Reputation: 143
I like pure relational design but sometimes there is a need for an Entity/Value method of storing data. Especially where the user needs to frequently create a new type of data.
I have seen in some commercial software that they dynamically create standard tables rather than use EV tables.
Obviously this isn’t a solve-all solution and can work only if you limit the sorts of data you can define. However, it has the following benefits:-
So to me this sounds great, but run the idea past a DBA and you get a lot of sucking of teeth. Is this a good idea, what are the pitfalls, and has anyone tried to do this?
Upvotes: 2
Views: 243
Reputation: 2324
Not too long ago, I built an online survey application. I used a hybrid form as database schema:
INSERT INTO temp_table SELECT ...
statement, using a lot of LEFT JOIN
s.This approach was ideal for this particular application, because a survey usually has a phase in which the answers are inserted, and a phase in which the results are analyzed.
So my advise: think about what the intended use is. This example only worked out because of the specific requirements of this application. Are you mainly inserting and updating values (OLTP)? Or do you want to run aggregate queries (OLAP)? Build your schema according to the answer on this question.
Upvotes: 1
Reputation: 7644
First of all: application should not be able to alter database structure, because they souldn't have the privileges to do so.
Second: I think the overhead of creating a good solution for creating a good database structure on the fly wouldn't pay off.
Third: It could cause some serious side effects with other things using the database (backups and maintaining scripts, other applications, etc.) when done improperly.
Upvotes: 2