identifying und non-identifying relationships

Die Schüler verwenden nach Möglichkeit nur non-identifying Relationships - ansonsten wimmelt es ruckzuck von Primärschlüsseln (und vor allem von zusammengesetzten Primärschlüsseln = würg).

Erklärung:

"Identifying Relationship - An identifying relationship is a relationship between two entities in which an instance of a child entity is identified through its association with a parent entity, which means the child entity is dependent on the parent entity for its identify and cannot exist without it. In an identifying relationship, one instance of the parent entity is related to multiple instances of the child." bzw. "Non-Identifying Relationship - A non-identifying relationship is a relationship between two entities in which an instance of the child entity is NOT identified through its association with a parent entity, which means the child entity is NOT dependent on the parent entity for its identify and can exist without it. In a non-identifying relationship, one instance of the parent entity is related to multiple instances of the child."
(http://www.datamodel.org/DataModelDictionary.html#NonIDRel , nicht mehr erreichbar)

Beispiel:

Ein Buch hat einen Besitzer, der Besitzer kann viele Bücher besitzen. Aber das Buch kann auch ohne Besitzer existieren oder den Besitzer wechseln. --> non identifying relationship.

Ein Buch wurde von einem Autor geschrieben, der Autor kann viele Bücher geschrieben haben. Das Buch kann NICHT ohne Autor existieren. --> identifying relationship.

Das bedeutet:

Der Fremdschlüssel (in Tabelle "Buch") wird Teil des Primärschlüssels, damit kann das Buch nicht ohne Autor ("parent") existieren. Anders ausgedrückt: Ein Buch kann nur mit Autor sinnvoll existieren - obwohl das Buch als eigene Entität modelliert wurde.

Eine non-identifying relationship liegt dann vor, wenn Primärschlüsselattribute des "parent" NICHT Primärschlüsselattribute des "child" (also des Buches) WERDEN DÜRFEN. Bei der Beziehung zwischen Lesern und Büchern (s.o.) sind die Bücher autonom, sie "brauchen" keine Leser, um zu existieren.

non-identifying relationships können OPTIONAL (NULL erlaubt) oder MANDATORY (NOT NULL) sein.

mehr dazu: Stack Overflow: What's the difference between identifying and non-identifying relationships?