My database has multiple tables that all rely on dates. I was wondering if it would be smarter for me to take the date attribute and throw it in a parent table, rather than give each table a date field. Here are two case examples (one with parent table, and one without):
Tables with parent table:
Schedule
--
PK ScheduleId : int
--
Date : date (unique)
Delivery
--
PK DeliveryId : int
--
Name : nvarchar(100)
Time : time(7)
--
FK ScheduleId : int
Exception
--
PK ExceptionId : int
--
Name : nvarchar(100)
--
FK ScheduleId : int
GenericEvent
--
PK GenericEventId : int
--
Name : nvarchar(100)
--
FK ScheduleId : int
Tables without parent table:
Delivery
--
PK DeliveryId : int
--
Name : nvarchar(100)
Date : date
Time : time(7)
Exception
--
PK ExceptionId : int
--
Name : nvarchar(100)
Date : date
GenericEvent
--
PK GenericEventId : int
--
Name : nvarchar(100)
Date : date
In the first case illustrated, everything references a unique Date entry. I'm split because I'm not sure if it would be better to search by the indexed foreign keys to get all the events (deliveries, exceptions, and generic events), or if it would be faster/ better practice to botch the Date parent table, and just search all the individual tables by a date field. The data model for the second case would look as follows:
The other bonus I would achieve from doing the first practice is that since I'm using entity framework, the object relationships would already be in place, and I could search for a date, and automatically receive all related deliveries, exceptions, and genericevents.
Thank you for your input, it's appreciated more than you know!
Date
andDateId
when it's adatetime
?