Welcome to PC Teach Me...

Free Computer Training Videos.

Although you do not need to register to access this site. Registering has its benefits. Such as:

  • Access to training material associated with the video you are watching [if applicable]
  • Automatic email updates when new training videos are available.
  • Ask for a training video.
  • Exclusive access to pose questions to me [limited availability as I am doing this for free :-)].
  • Free contribution of your own training topics, this includes referencing your videos outside of PC Teach Me.
  • Its Free!

Member Login

Lost your password?

Not a member yet? Sign Up!

By registering with this blog you are also agreeing to receive email notifications for new posts but you can unsubscribe at anytime.

25425 Registered Users
71 Number Of Articles
Free Video Tutorials (Email) Free Video Tutorials (RSS) Free Video Tutorials (Twitter) Free Video Tutorials (Flickr)

SQL: Primary Keys

sql SQL: Primary KeysSQL: Primary Keys

So if your here on this post your after understanding the mysteries of Primary/Foreign key relationships. Well let me tell you they are an art form not an exacting science something at first you may not appreciate until you deal with your own database schema’s.

SQL Relationships

To understand SQL Relationships it is important that you have covered the previous topics on here so I would recommend looking at the Select Statement  and the where clause before commencing this video.

All databases require primary keys. I have had arguments with people in the past saying “you don’t need them” I normally let them have just enough rope to hang themselves but make sure I have got the scissors on standby to save the day when they discover the need for them when duplicate orders or duplicate customers start cropping up in thier “brand new” database system.

The importance to SQL

I cannot stress to you all the importance of primary keys in SQL…..foreign keys are important but in my line of work (BI) I can quite often get away without using them as much. But Primary Keys are paramount in a database design as they make records unique and indexed. The final point I just mentioned about indexes will be covered in more detail on a separate video as the goal here will be to understand the symbiotic relationship these two elements have for each other.

This video is one of many SQL tutorials on this site click here for more

Related Posts

943 Comments

  1. ellie3637 says
    10 Nov 10 at 9:53pm

    Who is this person? He is such a GREAT teacher! I love his videos. Thanks a million.

  2. PCTeachME says
    07 Nov 10 at 2:33am

    @NYCEmpire Thanks, Good spot! I never said I was a good speller ;o) Post ammended.

  3. PCTeachME says
    07 Nov 10 at 2:33am

    @NYCEmpire Thanks, Good spot! I never said I was a good speller ;o) Post ammended.

  4. NYCEmpire says
    04 Nov 10 at 2:07pm

    Great video, as the rest of your videos. Although I am a bit surprised to see someone like you misuse “your” in place of “you’re”.

  5. NYCEmpire says
    04 Nov 10 at 1:07pm

    Great video, as the rest of your videos. Although I am a bit surprised to see someone like you misuse “your” in place of “you’re”.

  6. PCTeachME says
    30 Jul 10 at 12:14pm

    @Korn1holio Not a problem sir! Let me know if you have any questions.

  7. PCTeachME says
    30 Jul 10 at 11:14am

    @Korn1holio Not a problem sir! Let me know if you have any questions.

  8. Korn1holio says
    29 Jul 10 at 10:34pm

    Grateful for your video, thank you!

  9. ILMissKitty says
    17 Jun 10 at 8:52pm

    Thanks for your reply! I was not in the design view and could not figure it out. Thanks again for your reply..

  10. 17 Jun 10 at 7:52pm

    Thanks for your reply! I was not in the design view and could not figure it out. Thanks again for your reply..

  11. PCTeachME says
    17 Jun 10 at 3:30pm

    @ILMissKitty Hi, to answer that please refer to my other videos on the channel which are: 1. Microsoft SQL Diagrams 2. SQL Joins Hope these videos help! Please post any other questions you have. Thanks for getting in touch.

  12. PCTeachME says
    17 Jun 10 at 3:26pm

    @ILMissKitty Hi there! Sorry for the delay in replying. To answer your question you can set up only one primary key, but it can be across multiple fields (known as a composite key). In design view of the table, hold down the control key and click on each field which would (together) define uniqueness, when selected you click on the Primary key button on the toolbar. If you already have a primary key setup you would need to remove it first (click on the primary key button to remove)

  13. PCTeachME says
    17 Jun 10 at 2:30pm

    @ILMissKitty Hi, to answer that please refer to my other videos on the channel which are:

    1. Microsoft SQL Diagrams
    2. SQL Joins

    Hope these videos help! Please post any other questions you have. Thanks for getting in touch.

  14. PCTeachME says
    17 Jun 10 at 2:26pm

    @ILMissKitty Hi there! Sorry for the delay in replying. To answer your question you can set up only one primary key, but it can be across multiple fields (known as a composite key).

    In design view of the table, hold down the control key and click on each field which would (together) define uniqueness, when selected you click on the Primary key button on the toolbar. If you already have a primary key setup you would need to remove it first (click on the primary key button to remove)

  15. ILMissKitty says
    13 Jun 10 at 1:05pm

    Need more explanation on the joining table. Would be nice to know how to set two primary keys up.

  16. 13 Jun 10 at 12:05pm

    Need more explanation on the joining table. Would be nice to know how to set two primary keys up.

  17. 13 Jun 10 at 10:17am

    This is just what I was looking for. But how do you set up two primary keys in the table? I wanted to see more information on that part.

  18. PCTeachME says
    08 Jun 10 at 10:56am

    @rickstahr Hi Rickstahr, I’m sorry its too wordy, not sure how else to discuss Primary and Foreign keys without the theory :(

  19. PCTeachME says
    08 Jun 10 at 9:56am

    @rickstahr Hi Rickstahr,
    I’m sorry its too wordy, not sure how else to discuss Primary and Foreign keys without the theory :(

  20. PCTeachME says
    19 May 10 at 11:53am

    @dewi20 The table requires two keys to define uniqueness. Refering to Codd’s Data normalisation theories (from the 70’s), this would indeed be 3rd normal form. I had to look this up as I dont follow Codd’s concepts of Database design practices. Hope this helps.

1 2 3 48

Leave a Comment

You must be logged in to post a comment.

Valid XHTML 1.0 Transitional website security