The Database Approach and The Data Model
The Database Approach and The Data Model
DATA MODELS
Graphical diagram capturing nature and relationship of data
Enterprise Data Modelhigh-level entities and relationships for
the organization
Project Data Modelmore detailed view, matching data structure
in database or data warehouse
ENTITIES
Noun form describing a person, place, object, event, or concept
Composed of attributes
RELATIONSHIPS
Between entities
Usually one-to-many (1:M) or many-to-many (M:N), but could
also be one-to-one (1:1)
RELATIONAL DATABASES
Database technology involving tables (relations) representing
entities and primary/foreign keys representing relationships
One customer
may place many
orders, but each
order is placed by
a single customer
One-to-many
relationship
Therefore, one
order involves
many products
and one product is
involved in many
orders
Many-to-many
relationship
Relational Database
Relational Database
Relational database stores data in the form of tables
(also called a relation) with different tables linked to
each other via some data item.
Data can be accessed or reassembled from tables in
many ways without reorganizing the database tables.
Each table contains one or more data categories in
columns (also called fields).
Data values for every column are stored in rows, which
are also called tuples. Each tuple represent one record
value.
Relational Database
Relational Database
One-to-Many Relationships
Two tables are related in a one-to-many (1M) relationship if for every row in the
first table, there can be zero, one, or many rows in the second table, but for every
row in the second table there is exactly one row in the first table. For example,
each order for a pizza delivery business can have multiple items. Therefore,
tblOrder is related to tblOrderDetails in a one-to-many relationship. The one-tomany relationship is also referred to as a parent-child or master-detail
relationship. One-to-many relationships are the most commonly modeled
relationship.
One-to-many relationships are also used to link base tables to information stored in
lookup tables.
One-to-One Relationships
Two tables are related in a one-to-one (11) relationship if, for every
row in the first table, there is at most one row in the second table. True
one-to-one relationships seldom occur in the real world. The tables
tblPatient and tblConfidential are related in a one-to-one relationship.
The primary key of both tables is PatientId.
Tables that are related in a one-to-one relationship should always have
the same primary key, which will serve as the join column.
Many-to-Many Relationships
Two tables are related in a many-to-many (MM) relationship when for
every row in the first table, there can be many rows in the second table,
and for every row in the second table, there can be many rows in the first
table. Many-to-many relationships can't be directly modeled in relational
database programs,