From the course: Advanced MySQL Database Administration

Unlock this course with a free trial

Join today to access over 24,800 courses taught by industry experts.

Challenge: Primary key to foreign key mapping

Challenge: Primary key to foreign key mapping - MySQL Tutorial

From the course: Advanced MySQL Database Administration

Challenge: Primary key to foreign key mapping

- [Instructor] All right, we're ready for your next assignment, which is on primary and foreign key mapping. Again, Sally's coming to you with additional data requirements that are resulting from the launch of the new product. So in previous assignments, you've added the products table. You've updated the order items table to include a product ID, and she would like to make sure that the proper primary and foreign key relationships exist between those tables. This is important because going forward it will help ensure the data integrity of those tables. For example, let's say in the future you had four products, product ID one through four. If someone tries to enter a value of five or six into the order items table, which is an invalid ID, because of that foreign key to primary key relationship, it's going to prevent that from happening and you'll preserve the integrity of your data. So the only tip I'll give you here is you can do this using code or you can do it using the UI…

Contents