Reputation: 16609
I am trying to design a database for my app and webservice, Lets say the table for View properties is something like this:
So View has prop_id, x, y, width, height, bg_color, txt_color
And after a while i need to add a new column to this table like:
text_size, has_shadow ...etc
The type of property is dynamic, and the number of properties is dynamic as well.
so how can we design for such kind of extendable databases?
Upvotes: 0
Views: 154
Reputation: 47464
When you need a new property, you add a column to your table.
I'm sure that people will suggest that you try to use the EAV (Entity-Attribute-Value) model to accommodate these kinds of database changes, but that's a huge mistake, IMO. There are very, very few instances where that anti-pattern is called for, and this isn't one of them.
If your database needs to now track "text_size" then presumably your application will require changes that deal with this text size. You're going to have to change your application and/or database as it is, so you buy nothing (other than headaches) by using the EAV model.
If you Google EAV then you can find a lot more information on it and why it's a bad idea, but in a nutshell it makes querying your database more difficult and less performant, and makes maintenance more difficult, not easier.
Upvotes: 2