Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
Database Design
»
Design Ideas and Questions
»
database design help please
database design help please
Rate Topic
Display Mode
Topic Options
Author
Message
gf-350872
gf-350872
Posted Wednesday, January 23, 2013 7:44 PM
Forum Newbie
Group: General Forum Members
Last Login: Sunday, January 27, 2013 9:34 PM
Points: 2,
Visits: 10
Hi I am having some trouble on how to normalize some tricky tables.
Basically it is a recurrence event table that can either be daily, weekly, monthly or yearly.
I have made it so each recurrence row in the header table can have one id for either daily, weekly, monthly or yearly. This id corresponds to the appropriate table. Each table has different structures.
So here is an example of what I have.
Table: Recurrence
Columns: RecurrenceId (PK), RecurrenceDailyId(FK), RecurrenceWeeklyId (FK),
RecurrenceMonthlyId (FK), RecurrenceYearlyId (FK)
Table: RecurrenceDailyId
Columns: RecurrenceDailyId(PK), EveryDays, DayOfWeek etc
Table: RecurrenceWeeklyId
Columns: RecurrenceWeeklyId(PK), EveryWeeks, TimesAWeek etc
etc
What is the best way to create this structure so it is normalized? am I on the right path?
Post #1410874
Grant Fritchey
Grant Fritchey
Posted Thursday, January 24, 2013 8:14 AM
SSChampion
Group: General Forum Members
Last Login: Yesterday @ 3:40 PM
Points: 13,380,
Visits: 25,164
Nah, I'd say you're digging a bit of a hole. Instead how about something like
Recurrence ... whatever columns are unique to the recurrence
RecurrenceSchedule ... just a listing of each of the types, daily, monthly, etc., and any unique values to them
RecurrenceScheduleType ... a join between the schedule and the recurrance. Probably make the primary key the two tables keys, but put a unique constraint on the Recurrence key in addition so that a recurrence can only have one type.
The other method involves a lot of null values and joins to tables without data. This will ensure you always get data back.
----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of:
SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans
Product Evangelist for
Red Gate Software
Post #1411161
gf-350872
gf-350872
Posted Sunday, January 27, 2013 9:53 PM
Forum Newbie
Group: General Forum Members
Last Login: Sunday, January 27, 2013 9:34 PM
Points: 2,
Visits: 10
Thanks
Post #1412174
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.