Join Adam Wilbert for an in-depth discussion in this video Creating composite primary keys, part of Database Fundamentals: Storage.
- Creating composite primary keys in your database…is done much the same way as adding…regular primary keys.…Let's take a look using the Graphical User Interface,…in the H+ Active Database I'll come to the Tables folder,…right click and choose Table to start up…a new design view for our tables here.…Now what I want to do is recreate one of the tables…that we outlined in the last chapter,…and specifically the customer credit card table.…If you remember, when we did the outline,…we specified that we wanted a composite primary key…consisting of the CustomerID field…and a CreditCardNumber field.…
So let's go ahead and create those fields.…The CustomerID will be the int data type,…and the CreditCardNumber will be a char(16) data type.…In the outline, we also had a third column…called PrimaryPayment, and that was just going to store…a yes or no of whether this credit card…was this particular customer's primary form of payment,…and we can do that with with the bit data type here.…
Now in order to set two columns as a primary key,…
Note: This course will also prepare certification candidates for the "Understanding data storage" domain of the Microsoft Technology Associate (MTA) Exam 98-364, Database Administration Fundamentals. Find out more at https://www.microsoft.com/learning/en-us/exam-98-364.aspx.
- Reducing redundancy with normalization
- Fixing partial dependencies
- Creating primary keys
- Linking tables with foreign keys
- Creating clustered and nonclustered indexes