I have made a small database for a daycare centre. I have been reading up on identifying and non-identifying relationships and am still a bit confused about the whole thing. I have been using MySQL Workbench to design the database.
Now, the criterias for parents and children are that a Parent
can have one or more Children
and vice versa - ergo, the relationship between Parents
and Children
is a many-to-many. The best praktice to solve this (as I understand) is to make a third table - Parets_Children
and use that as a "connection" between the other two:
Parents - 1:n - Parents_Children n:1 - Children
Now the issue I have is wether or not to use an identifying relationship here. The logic is that no child can exist without a parent and the parents wouldn't be members of the daycare unless they had at least one child there. Neither of them would exist "alone". However, when letting MysQL WB sorting it out for me, it creates a non-identifying relationship (I think).
Very simplified code:
CREATE TABLE 'parents' (
'id_parents' SMALLINT UNSIGNED NOT NULL ,
'name' VARCHAR(48) NOT NULL ,
PRIMARY KEY ('id_parents');
CREATE TABLE 'parents_children' (
'id_parents' SMALLINT UNSIGNED NOT NULL ,
'id_children' SMALLINT UNSIGNED NOT NULL ,
PRIMARY KEY ('id_parents', 'id_children') ,
FOREIGN KEY ('id_parents') REFERENCES 'parents' ('id_parents' )
FOREIGN KEY ('id_children' ) REFERENCES 'children' ('id_children' );
CREATE TABLE 'children' (
'id_children' SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT ,
'name' VARCHAR(48) NOT NULL ,
PRIMARY KEY ('id_children');
Would this output be sufficient to reach the desired function? Have I misunderstood the whole relationship thing? I hope my question isn't too obsqure.