Within
data modelling, cardinality is the numerical relationship between rows of one table and rows in another. Common cardinalities include ''one-to-one'', ''one-to-many'', and ''many-to-many''. Cardinality can be used to define data models as well as analyze entities within datasets.
Relationships
For example, consider a database of
electronic health records
An electronic health record (EHR) is the systematized collection of electronically stored patient and population health information in a digital format. These records can be shared across different health care settings. Records are shared thro ...
. Such a database could contain tables like the following:
* A
doctor
table with information about physicians.
* A
patient
table for medical subjects undergoing treatment.
* An
appointment
table with an entry for each hospital visit.
Natural relationships exist between these entities:
* A many-to-many relationship between records in
doctor
and records in
patient
because doctors have many patients and patients can see many doctors.
* A one-to-many relationship between records in
patient
and records in
appointment
because patients can have many appointments and each appointment involves only one patient.
* A one-to-one relationship is mostly used to split a table in two in order to provide information concisely and make it more understandable. In the hospital example, such a relationship could be used to keep apart doctors' own unique professional information from administrative details.
Modeling
In
data modeling
Data modeling in software engineering is the process of creating a data model for an information system by applying certain formal techniques. It may be applied as part of broader Model-driven engineering (MDE) concept.
Overview
Data modeli ...
, collections of data elements are grouped into "data tables" which contain groups of data field names called "database attributes". Tables are linked by "key fields". A "primary key" assigns a field to its "special order table". For example, the "Doctor Last Name" field might be assigned as a primary key of the Doctor table with all people having same last name organized alphabetically according to the first three letters of their first name. A table can also have a foreign key which indicates that field is linked to the primary key of another table.
Types of models
A complex data model can involve hundreds of related tables. Computer scientist
Edgar F. Codd
Edgar Frank "Ted" Codd (19 August 1923 – 18 April 2003) was a British computer scientist who, while working for IBM, invented the relational model for database management, the theoretical basis for relational databases and relational database ...
created a systematic method to decompose and organize
relational databases.
Codd's steps for organizing database tables and their keys is called
database normalization
Database normalization is the process of structuring a relational database in accordance with a series of so-called '' normal forms'' in order to reduce data redundancy and improve data integrity. It was first proposed by British computer scien ...
, which avoids certain hidden database design errors (delete anomalies or update anomalies). In real life the process of database normalization ends up breaking tables into a larger number of smaller tables.
[
]
In the real world, data modeling is critical because as the data grows voluminous, tables linked by keys must be used to speed up programmed retrieval of data. If a data model is poorly crafted, even a computer applications system with just a million records will give the end-users unacceptable response time delays. For this reason, data modeling is a keystone in the skills needed by a modern software developer.
Database modeling techniques
The entity–relationship model
An entity–relationship model (or ER model) describes interrelated things of interest in a specific domain of knowledge. A basic ER model is composed of entity types (which classify the things of interest) and specifies relationships that can e ...
proposes a technique that produces entity–relationship diagrams (ERDs), which can be employed to capture information about data model entity types, relationships and cardinality. A Crow's foot shows a one-to-many relationship. Alternatively a single line represents a one-to-one relationship.
Application program modeling approaches
In the object-oriented application programming paradigm, which is related to database structure design, UML class diagrams may be used for object
Object may refer to:
General meanings
* Object (philosophy), a thing, being, or concept
** Object (abstract), an object which does not exist at any particular time or place
** Physical object, an identifiable collection of matter
* Goal, an a ...
modeling. In that case, object relationships are modeled using UML associations, and multiplicity is used on those associations to denote cardinality. Here are some examples:
See also
*Arity
In logic, mathematics, and computer science, arity () is the number of arguments or operands taken by a function, operation or relation. In mathematics, arity may also be called rank, but this word can have many other meanings. In logic and ...
* Entity-relationship model
*Unified modeling language
The Unified Modeling Language (UML) is a general-purpose visual modeling language that is intended to provide a standard way to visualize the design of a system.
UML provides a standard notation for many types of diagrams which can be roughly ...
References
External links
UML multiplicity as data model cardinality
- http://www.agiledata.org
Cardinality in Data Modeling
- Adam Alalouf, Temple University
Cardinality
on Techopedia
Cardinality
on Geeksforgeeks
Database Cardinality
on SQL World
{{DEFAULTSORT:Cardinality (Data Modeling)
Data modeling
Relational model
de:Kardinalität (Datenbanken)
pt:Cardinalidade (modelagem de dados)