Featured post
sql - Design Pattern to add columns in database table dynamically -
the user wants add new fields in ui dynamically. new field should stored in database , should allowed perform crud on it.
now can specifying xml wanted better way these new columns searchable. idea of firing alter
statement , adding new column seems wrong.
can me design pattern on database server side of how solve problem?
this can approached using key value system. create table primary key column(s) of table want annotate, column name of attribute, , column value. when user wants add attribute (say height) record of person 123 add row new table values (123, 'height', '140.5').
in general cast values text storage if know attributes numeric can choose different type value column. can (not recommended) use several different value columns depending on type of data.
this technique has advantage don't need modify database structure add new attributes , attributes stored records have them. disadvantage querying not straightforward if columns in main data table.
- Get link
- X
- Other Apps
Comments
Post a Comment