What is a child table in an identity or non-identity relationship?

In the context of identifying and not identifying relationships between tables, MySQL documentation refers a lot to tables as parent and child tables.

How do you determine which table is the parent table and which table is the child table?

+5
source share
3 answers

A children's table (AKA weak object ) is a table whose primary key attributes depend on another table, so the child table is identified or partially identified by the rows in the table in which it depends (parent). Rows in a child table cannot exist without the corresponding row in its parent table.

To illustrate, let's look at a simple and fully relevant example that we are all familiar with: parents and children in the context of a family. We can model this relationship with tables like this:

Parent to Child Identifying Relationship

Parents SSN. SSN , "" , , .

(Parent_SSN SSN Parents).

(Parent_SSN, Name) Children. , Parent_SSN Name. , Name, . , , Parent_SSN, . , , .

SSN? , . , :

Parent to Child Non-Identifying Relationship

, SSN Children. SSN. Parents. Parent_SSN - SSN Parents, , , "" .

, :

  • , .
  • Parent_SSN NULL , , , / .

Parents Children. , , Parents Parent_SSN, Parent_SSN / SSN Parents, .

, , / , , :

Employee Department Relationships

.

: (DeptNo Employee), (ManagerSSN Department), - ?... ?

- ? DeptNo Employee, DeptNo / Department.

Employee ManagerSSN Department, ManagerSSN / Employee.

+9

, . , : .

, , . : order, order_details , order , order_details .

, . : orders customers. , orders, customer, customers orders - . ( customers) order, , order , customers .

, 70- , ( ) .

0

:

A relative relationship is when the existence of a row in a child table depends on a row in the parent table. (...) Formally, the “right” way to do this is to make a foreign key [i.e. parent primary key] part of the child primary key.

0
source

All Articles