Join Adam Wilbert for an in-depth discussion in this video Linking tables with foreign keys, part of Database Fundamentals: Storage.
- Once a primary key is established on a table,…others tables can make use of that field…with establishing relationships.…These relationships will link a copy…of the primary key data that's stored in the related table…in a field called the foreign key.…Now before we get too far into this,…I want to load up some additional data tables…that I've got stored inside of our exercise files.…Go ahead and find a file called DatabaseReset.txt…and I'm going to start a new query here,…and just paste in all of that text.…Now this is quite a long script,…it's going to go through and create some new data tables…and populate them with data.…Let's go ahead and just press the Execute button,…and after a moment you'll get this message down here…saying that one row is affected,…and we have that multiple times,…and if we come over here to our H+ Active database,…I'l right click and say Refresh,…and then if we expand our tables we'll notice…that we have a lot more tables to work with now.…
Let's go ahead and close this query,…and I will not save any changes.…
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