I have a set of tables in database where I cannot change its structure. I need to create extensions to the tables by adding new attributes (columns). The list of columns and their data types is determined dynamically by the applications that use the database.
I thought of using an EAV approach for the extensions, or create a table with a XML column to store the variable extensions and maintain a relational structure. Another possibility is a hybrid approach where I would create an EAV for the metadata only, and use the XML for storing the data.
I would appreciate if someone could comments on the options or enlighten me with different ideas.
If the columns being added are not added by the whim of an end user, consider multiple "sister tables" in a star schema. Although that can add a bit o' complexity to code, it allows real data-typing of the new columns, can be fast as the wind, and also easily allows for DRI.
If you decide to go the EAV route and you have no "blob" data, read up on the SQL_VARIANT datatype which allows for some semblance of metadata preservation (I use it for column-level Audit tables).
I share Elliott's and Grant's observations on XML except I'll go several steps further. I feel that it's a grossly overused, over advertised, resource intensive, difficult to maintain, pipe clogging, bloated method that should be avoided in a database at any and all costs because it's worth avoiding.
Heh... strong letter to follow. :-P
is pronounced ree-bar and is a Modenism for R
First step towards the paradigm shift of writing Set Based code: Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair
How to post code problemsHow to post performance problemsForum FAQs