So, I'm writing this Student Programmer Orientation and Training (SPOT) program for work. I'm at a part where I am writing some basics about database design. Specifically I'm writing about relationships. More specifically I'm writing about 1:1 relationships.
The issue is this: 1:1 relationships are really the most complicated IMO. They can be done either like 1:N, or like N:N. Of course when you use a third table to describe the relationship (like N:N) this is more normalized. But using a foreign key, like in a typical denormalized 1:N, is much more common.
At first I didn't realize this. I though, "oh, I'll start with 1:1, go to 1:N, and then do N:N." But I ended up just moving 1:1 to the end, since it could be done like either of the other two. I realize now I left out the part where a 1:N relationship can be described with a third table, but maybe I'll put that in a quiz to see if they can figure it out on their own. (smirk)
Also, its kind of hard to come up with examples, in my opinion. I used Oregon Drivers License record and Social Security record as my two records that have a one to one relationship. Since ODL will only be associated with one SSN, and they won't issue an ODL to someone who has a SSN with an ODL already associated with it, this is perfect.
And I've only written one program that actually uses a table with a 1:1 relationship. I guess its common to use when you have a special group of users. I might have to go back and do that. User ID foreign key . . . reason for being serperate from the rest of the table . . . sounds good to me.
Anyways,
:p
Wednesday, August 12, 2009
Subscribe to:
Posts (Atom)