Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does it make sense to create new table or add fields

I apologize if this is just another way of asking about storage space on a MySQL table such as these: NULL in MySQL (Performance & Storage)

but my question really pertains to best practice.

The Problem

Let's assume I have a table which collects all 'necessary' information from a customer at a given point in time. 12 months down the road, I realize I would also like to capture the person's date of birth and gender if they wish to supply it (the number of fields is somewhat irrelevant but understand it could be one or 50 additional fields).

Is it best practice to add the new fields into my existing table, setting and allowing all initial values to be NULL, then updating existing records with the new data

OR

create a new table(s) and establish a relationship with the primary table based on the presence of the primary key?

like image 343
JM4 Avatar asked Sep 08 '11 18:09

JM4


1 Answers

Don't worry so much about when the columns are added to the table, whether it's today or 12 months later. Instead, just think about the relationships involved. There's a 1:1 relationship between a person and their gender and birthday, so it makes sense to keep these attributes in the existing table rather than creating a new one.

like image 74
Joe Stefanelli Avatar answered Sep 23 '22 19:09

Joe Stefanelli