0

Let's say we have predefined form that has 3 fields : FirstName, LastName, Email and this form is mapped to table users with : ID, FirstName, LastName, Email

Let's say a user want to add a new field for instance BirthDate. the user will pick the type of the field, here DateTime texbox and the text beside the field like Birth Date but how to add this column in the users Table?

Any help would be highly appreciated

Joseph

1 Answer 1

1

There is no realistic way for a user to dynamically add a field to the actual database table, not so that you have a new field like 'DateOfBirth' or 'ShoeSize'.

You can however, capture dynamic data from users by changing the core design of your application. Instead of storing your data in a fixed 'horizontal' table what you need to do is abstract your database and store each value as a seperate record - kind of like a 'vertical' table.

So you would have a table like

Field, Data, Type
---------------------------
"FirstName", "John", string
"LastName", "Smith", string
"DateOfBirth", "01/01/1950", datetime
"ShoeSize", "4", int

Its a issue of architecture not of technology.

There is a really good article here that discusses it in much greater depth.

It is important to understand that this does make your application quite a bit more abstract, less type safe and as such far more complex. I would not suggest trying to do this unless you fully understand the extra work involved.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.