WEBDEV Concepts

164 Part 5: Databases 3 Characteristics of the links defined in an analysis 3.1 Owner file and member file When a link is defined between two data files, there is an owner data file and a member data file: • the owner data file is the owner of the key. • the member data file is a member of the analysis data files containing a copy of the key. To set the link between two data files, the key of the owner data file is copied to the member data file. For example, the key of the Supplier data file is copied to each record of the Product data file. Several records of the Product data file can have the same key of the Supplier data file: • Supplier is the owner data file, • Product is the member data file. This type of link is represented as follows: 3.2 Cardinalities Cardinalities are used to count the relationships between two data files. Cardinalities are defined according to the answers to the two following questions: 1. For each record of the data file, what is the minimum number of records in the other data file this record is linked to? The answer provides the first part of the cardinality ( minimum cardinality ): • if the answer is "none", the cardinality is 0,X. • if the answer is "a single one", the cardinality is 1,X. 2. For each record of the data file, what is the maximum number of records in the other data file this record is linked to? The answer provides the second part of the cardinality ( maximum cardinality ): • if the answer is "a single one", the cardinality is X,1. • if the answer is "several", the cardinality is X,N. The answer to these two questions defines the cardinality that can be: 0,1 ; 0,N ; 1,1 ; 1,N The description of cardinalities is essential: it is the basis for respecting the referential integrity of the database. To put it simply, these two questions can be broken down into four questions. For example, to describe a link between the Club data file and the Person data file: • each "Club" has at least one "Person": Yes/No? • each "Club" can have several "Persons": Yes/No? • each "Person" has at least one "Club": Yes/No? • each "Person" can have several "Clubs": Yes/No? Example of cardinalities : This example presents two different cardinalities: • 0,1 cardinality : A person can be a member of a single sport club. This person does not have to belong to a sport club. • 0,N cardinality : A club can have no member or several members.

RkJQdWJsaXNoZXIy NDQ0OA==