Database Reference
In-Depth Information
Figure 8-2. Executing the create table statement (parent-child relationship)
4. Next let's insert some data into the Person and PersonDetails tables; execute
the statement in Listing 8-2, and click Execute.
Listing 8-2. Create Parent-Child Relationship
Insert into Person
values('Vidvr','Vidya Vrat','Lionbridge Inc'),
('Rupag','Rupali', 'Pearl Solutions')
This statement should show the status “(2 row(s) affected).”
A child can have only those records that map to the parent; hence, we can insert only child records
in PersonDetails for those PersonIDs that are already available in the Person table.
Insert into PersonDetails
values('Vidvr','Bellevue WA 98007'),
('Rupag', 'Bellevue WA 98007')
As you can see, the child table's PersonID matches with the parent table.
So, now we have a perfect parent-child relationship, where we have two parent records and two
matching child records in the Person and PersonDetails tables, as shown in Figure 8-3.
Search WWH ::




Custom Search