Thursday, September 24, 2009

Muddiest Point for 09/22 Lecture

I don't know what it is, but I'm really not getting the distinction between foreign and primary keys. I didn't see, in the lecture, why which one in the example was which.

3 comments:

  1. I had the same sort of confusion on the the keys. Dr. He did talk more extensively about it in lecture on 09/21. The primary key is clear because it serves as the main identifier. Where I get confused is with the foreign key. To me it convolutes the information by sticking the primary key in with another identifier. I don't know if I am actually thinking of this correctly but I still can't wrap my mind totally around it.

    ReplyDelete
  2. Keys are identifiers. Primary keys are the unique identifiers for a given database. Foreign keys are primary keys from other databases that, for whatever reason, have been placed in another database. So rather that repeating information over and over again (from Dr. He's example, information about a painter.) in one database, we create two databases. One database has all the information about a set of painters, and each painter is assigned a primary key. That primary key is used in other databases and in those other databases is known as the foreign key.

    Using the foreign key/primary key paradigm allows us to edit databases easily. If anything about the painter information changes, we need only change it once in the painter database, and don't have to edit the painting database, since all the painting database contains is the foreign key, linking it back to the painter database.

    ReplyDelete
  3. Okay, thanks Tim! That actually makes a lot more sense now.

    ReplyDelete