Steve
Steve

Reputation: 40

Should I normalize a database with a column for each day of the week?

Designing an oracle database for an ordering system. Each row will be a schedule that stores can be assigned that designates if/when they will order from a specific vendor for each day of the week.

It will be keyed by vendor id and a unique schedule id. Started out with those columns, and then a column for each day of the week like TIME_SUN, TIME_MON, TIME_TUE... to contain the order time for each day.

I'm normally inclined to try and normalize data and have another table referencing the schedule id, with a column like DAY_OF_WEEK and ORDER_TIME, so potentially 7 rows for the same data.

Is it really necessary for me to do this, or is it just over complicating what can be handled as a simple single row?

Upvotes: 0

Views: 282

Answers (2)

phonetic_man
phonetic_man

Reputation: 1088

Normalization would be advisable. In future if you are required to store two or more order times for the same day then just adding rows in your vendor_day_order table will be required. In case you go with the first approach you will be required to make modifications to your table structure.

Upvotes: 0

Vaibhav G
Vaibhav G

Reputation: 11

Normalization is the best way. Reasons:

  • The table will act as a master table
  • The table can be used for reference in future needs
  • It will be costly to normalize later
  • If there are huge number of rows with repeating more column values then database size growth is unwanted
  • Using master table will limit redundant data only to the foreign key

Upvotes: 1

Related Questions