From the course: Learning Relational Databases
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Solution: Establish relationships with CoderPad
From the course: Learning Relational Databases
Solution: Establish relationships with CoderPad
(upbeat music) - [Instructor] For this challenge, we need to add in a relationship between the customers and the invoices table in the two trees database. This will help ensure that the data that we put into the database has referential integrity. For example, we're given this insert statement which will add in a row of data into the invoices table. I'm going to uncomment out this line by deleting the two hyphens and just execute it right now. Now it tells me that it's incorrect for this challenge, but the database has no problem inserting that data into the invoices table, and I can see it listed here in the result. The problem is, is that the customer's table doesn't yet have any customers in it, yet here we're referring to customer ID number one for this invoice. It doesn't actually point to any valid customer data. That's a huge problem. So to prevent this from happening, we need to put in a constraint that says that we can only enter invoices that have a valid customer ID number…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
(Locked)
Move from planning to construction3m
-
(Locked)
Solution: Create the tables with CoderPad4m 19s
-
(Locked)
Solution: Establish relationships with CoderPad3m 16s
-
(Locked)
Solution: Write queries in CoderPad4m 6s
-
(Locked)
Create the tables in Access8m 24s
-
(Locked)
Establish relationships in Access4m 41s
-
(Locked)
Write queries in Access3m 59s
-
(Locked)
Create the tables in SQL Server9m 22s
-
(Locked)
Establish relationships in SQL Server5m 48s
-
(Locked)
Create views in SQL Server4m 43s
-
(Locked)
-