Subject | Database design question |
---|---|
Author | kogerbnz |
Post date | 2008-01-24T22:07:56Z |
Hello
First, I hope this is the right group to ask a design question. If I
choose the wrong one, then I'm sorry, but please tell me where to go.
I have a database design problem, that I'm not sure I have solved in
the best way.
I have a user table. Each user can make a log once a day. So I'm
creating a new table which has UserID as a foreign key and a primary
key which is a combination of UserID (the FK) and a date column.
Is that a good design?
--UserTable--
ID (PK)
...
--DailyLogTable--
UserID (FK and also Part of PK)
Date (Part of PK)
...
Or would it be better to have an artificial auto incremented PK, and
make a constraint not allowing two rows with the same UserID and date.
--DailyLogTable--
ID (PK)
UserID (FK)
Date
...
In a way the last seems a bit more straight forward, but does add an
extra column and constraint.
Thank you for your comments
First, I hope this is the right group to ask a design question. If I
choose the wrong one, then I'm sorry, but please tell me where to go.
I have a database design problem, that I'm not sure I have solved in
the best way.
I have a user table. Each user can make a log once a day. So I'm
creating a new table which has UserID as a foreign key and a primary
key which is a combination of UserID (the FK) and a date column.
Is that a good design?
--UserTable--
ID (PK)
...
--DailyLogTable--
UserID (FK and also Part of PK)
Date (Part of PK)
...
Or would it be better to have an artificial auto incremented PK, and
make a constraint not allowing two rows with the same UserID and date.
--DailyLogTable--
ID (PK)
UserID (FK)
Date
...
In a way the last seems a bit more straight forward, but does add an
extra column and constraint.
Thank you for your comments