Search code examples
sql-servertypesnormalization

SQL Server Normalisation/Best Practices: Single Data Table


I have inherited the maintenance of a database from a former employee in another department and I believe their database development skills are not really up to snuff.

I have been asked to support or redevelop it.

It appears the database of the data for each record is in one single table, Yes I know and has hundreds of thousands of rows with empty fields.

TableData:
> RowID
> FieldID
> DateData
> NumberData
> TextData
> YesNoData

Only one field (dependent on the datatype required) appears to be populated in this instance for each row - the rest are empty.

There are two other tables which identify details of the Record (Created by etc) and the Field (Updated On, Field datatype)

Looking through the Access front-end code it appears that data for each field and record and field is stored by searching on record and field and then returning the appropriate field with the data.

My question: For what purpose does this achieve, or is this type of development considered the work of an inexperienced database developer?


Solution

  • My best guess is that a table like this is used to store arbitrary data (inferred from the other supporting tables) that won't require schema changes to store information that is "unplanned" or not yet implemented in the business logic of the application.

    The questions I would start asking (yourself, any programmers, DBA's, project managers, etc.):

    • Were the requirements so abstract at the time that it was impossible to create a formal schema with data relationships? (Bad, bad, BAD)
    • Was the database designer lazy or inexperienced?
    • Was the programmer lazy or inexperienced? (Better yet, was the programmer the DBA?)
    • Is the reliability/availability of the data so sensitive that making formal schema changes is hard to do on a regular basis?
    • Has the project gone through plenty of people before you that simply inherited the problems, and this is a hack solution? (While maybe the original programmer knew where it was intended to go eventually...)

    I think what you're really trying to get at here is "does this work, or should I change it?". I'd be shocked if the any read/search queries are optimized at all, as there couldn't be any indexes for such arbitrary data storage. If the application is simply logging information, it probably isn't as big of a deal, as the originator probably just didn't know yet how the data would be used later on, and writing a one-time applet to loop through and create formal objects out of the data would be better than trying to assume everything at the beginning.

    Getting a little more targeted, are you running into any bottlenecks in your process because of this particular table, or are you concerned just out of surprise? If the former, I'd figure out how to change it right away. If the latter, I'd take my time figuring out the long-term requirements of the application first.