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.

25426 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


  1. John Madison says
    23 Jul 15 at 6:16am

    0:51-0:53: Access: Use NorthWind Database.
    0:55-1:02: MySQL Server, can use NorthWind database that you can get from
    microsoft’s website.
    1:02-1:06: The rest of you will just have to follow along.
    9:24: Order#1 cannot have 2 keys for the same product.
    I kind of get this. But doesn’t make sense if there is only ONE
    order one
    which can only have ONE productID key. You wouldn’t be stopped from
    duplicate products. It just, wouldn’t be possible. Because there is
    only one slot
    for one product.
    9:36 – 9:52: Many To Many relationship.
    One order can have many OrderDetails.
    One product can be in many OrderDetails.
    OOoh… Okay. I get it now.
    Also, when thinking of the OrderDetails table and the two keys.
    Just imaging gluing both keys together. The glued result MUST be unique.
    Don’t forget to use leading zeros in this visualization.

    9:52: When you join a table where on both sides, the item would be unique.
    You will get a many-to-many relationship that uses TWO primary keys.
    Both of those primary keys being FORIEGN keys because they come from the
    other tables.

    10:00 – 10:19:
    Don’t think a primary key is one field, because it could be many.

  2. faiz siddiqui says
    12 Jun 15 at 11:47am
  3. Fabian Vasquez says
    15 Dec 14 at 4:25am

    Great tutorial. Thank you!

Leave a Comment

You must be logged in to post a comment.

Valid XHTML 1.0 Transitional website security