r/DatabaseHelp • • May 28 '15

allocating time to entity

Is it good to separate time into entity which is skipped every 5 minutes from 7AM to 11PM which predefined rows?
Example rows:
7:00, 7:05, 7:10, ..., 22:55, 23:00

1 Upvotes

4 comments sorted by

View all comments

Show parent comment

1

u/wolf2600 May 29 '15 edited May 29 '15

So you have a table:

Schedule
-----------------
ScheduleID
Name
StartTime
EndTime

And you're thinking about creating another table which would just contain times, so you would reference the TimeID for StartTime and EndTime instead of the literal time?

Times
-----------------
TimeID
Time

If you're normalizing for a school project, then that might make sense as it would "technically" put the schema into 3NF, but in practice, it's really not needed.

If you were implementing the Schedule table in real-life, my suggestion would be to make the StartTime and EndTime columns be char(4) datatypes, and in your database frontend (whatever method you'll be using to insert new records into the table), I'd apply data validation to ensure that the values consist of 4 numeric characters, from 0000 to 2359, representing the hours/minutes