• N_Muller (12/12/2013)


    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. 😛

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    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.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)