[thelist] Magic data table

Edwin Horneij ed_horneij at yahoo.com
Tue Aug 17 13:06:04 CDT 2004


I may have inherited a project from another developer, and I am not
sure what to do about the database structure he created. It is
impressive, but strikes me as somewhat unorthodox.

He has created a kind of "one size fits all" meta-table that contains
everything -- HTML templates, product information, user registration
info, and probably a lot more.

The columns are named like this: "Field_1_Name", "Field_1_Type",
"Field_1_Value", "Field_2_Name", and so on. Queries take the form
"SELECT * FROM Content WHERE Field_1_Name = 'First Name' AND
Field_1_Value = 'Edwin'".

My predecessor seems to have also written PHP code that changes the
structure of the table where necessary. For example, if a newly
submitted value for a given entity's attribute exceeds 255 characters,
the system moves all of the data for that attribute of that type of
entity from the default varchar column to a text column. I _think_ it
will also add new columns to accomodate more attributes than there are
columns available, should that be necessary.

Hopefully the above description is clear enough for my question to make
sense. I have never seen anything like the current set-up, but my
database knowledge is pretty basic. Is this method standard practice? I
had thought that different types of entities were supposed to have
different tables, and I don't see the advantage of the method my
predecessor has adopted. It is not too late for me to make changes to
the database structure, but on the other hand, I don't want to fix
something that may not be broken.

Any help would be much appreciated.



 


		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail 


More information about the thelist mailing list