0% found this document useful (0 votes)
14 views51 pages

Data Model (Extra) - 113538

The document provides an overview of data models, emphasizing their importance for database designers and end-users to communicate effectively about organizational data. It details various types of data models, particularly the Entity-Relationship (ER) model, which helps in capturing and representing data, entities, relationships, and attributes. Additionally, it discusses the characteristics of entities, attributes, keys, and relationships, including cardinality and types of relationships.

Uploaded by

freyurasa34
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views51 pages

Data Model (Extra) - 113538

The document provides an overview of data models, emphasizing their importance for database designers and end-users to communicate effectively about organizational data. It details various types of data models, particularly the Entity-Relationship (ER) model, which helps in capturing and representing data, entities, relationships, and attributes. Additionally, it discusses the characteristics of entities, attributes, keys, and relationships, including cardinality and types of relationships.

Uploaded by

freyurasa34
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 51

MS 213:DATA MODELS

Lecture 3
PREPARED BY
Mr. Siphael Betuel
Data Models

▪ Database designers and end-users need to


communicate unambiguously and accurately
understanding the organizational data
▪ They need a high level description of the data, that is
Data model
Data model?
• A collection of concepts that can be
used to describe and manipulating data,
relationships between data, and the
constraints on the data in an
organization
• A model is a representation of real-
world objects and events and their
associations
TYPES OF DATA MODELS

1. The Entity-Relationship Model


2. Relational Model
3. The Object-Relational Data Model
4. Hierarchical Model
5. The Network Data Model
The Entity-Relationship Model

• Different techniques can be used to gather and


capture information about what the users require of
a database system.
• Once the requirements collection and analysis stage
of the database system development lifecycle is
complete and we have documented the requirements
for the database system, we are ready to begin the
database design stage.
The Entity-Relationship Model

• One of the most difficult aspects of database design


is the fact that designers, programmers, and end-
users tend to view data and its use in different ways.
• we need a model for communication that is
nontechnical and free of ambiguities. The Entity–
Relationship (ER) model is one such example
Entity-Relationship (ER)
Modeling.
▪ Entity Relationship (ER) Diagram–A detailed,
logical representation of the entities, associations
and data elements for an organization or
business
•Notation uses three main constructs
-Data entities
–Relationships
–Attributes
ERD CONTINUE…..

• The entity-relationship model allows


us to describe the data involved in a
real-world enterprise in terms of
objects and their relationships and is
widely used in develop an initial
database design.
ERD
• The ER model describes data as entities, relationships and
attributes.
• An entity is an object in the real world that is
distinguishable from other objects.
• e.g., person, company, event, plant etc
• Entity Sets : An entity set is a set of entities of the same
type that share the same properties or attributes.
• e.g., The set of all persons, companies, trees, holidays
etc.
ERD

• In ER, an entity is represented as a rectangle with the


name.
Types of Entities

❑Strong Entity
▪ These shapes are independent from other entities,
and are often called parent entities, since they will
often have weak entities that depend on them.
▪ They will also have a primary key, distinguishing each
occurrence of the entity.
Types of Entities

❑Weak Entity
▪ Weak entities depend on some other entity type.
▪ They don't have primary keys, and have no meaning
in the diagram without their parent entity.
ERD CONTINUE…

• An attribute is the property of an entity.


• E.g. an employee entity may be described by employee’s
name, age, address, salary etc.
• In ER model attribute is represented as an Oval.
ERD CONTINUE…

• Key Attributes : An entity type usually has an


attribute whose values are distinct for each individual
entity in the collection. Such an attribute is called a
key attribute and its values can be used to identify
each entity uniquely.
TYPES OF ATTRIBUTES
1. composite vs. simple attributes
• Simple attributes are attributes that can’t be
divided sub-parts. E.g salary.
• Composite attributes can be divided into smaller
subparts, which represents more attributes. E.g name
can be subdivided into first name, middle name and last name.
• Date of Birth is another example of composite attribute,
because it may be divided into “Birth day”, “Birth month” and
‘Birth year”.
Types OF attributes

2. Single-valued, Multi-valued and derived


attributes
Most attributes have a single value for a particular
entity, such attributes are called single valued. E.g
age for a person.
Multi-valued attributes have more than one value for
a particular attribute. E.g degree a person may
have more than one degree, Telephone number etc.
Types OF attributes

3. Stored vs derived attributes.


▪ In some cases two (or more) attributes are related;
e.g age and date of birth(DOB).
▪ The age can be determined from the DOB, so age is
a derived attribute and DOB is a stored attribute.
TYPES of ATTRIBUTES

4. Null values.
▪ In some cases a particular entity may not have an
applicable value for an attribute. E.g a person with
no college degree would have null for college
degree.
Data Type: MS access
 Text: Any alphabetical/numerical data that you desire
Examples of Text data are: names, addresses, stock numbers,
room numbers, zip codes, etc.
 Number :This field is for numbers where you want to add,
subtract, multiply, divide,
 Date/Time: Dates and Times. You may format these later,
as you may desire.
 Currency :Dollars ($). You may format these later, as you
may desire.
 AutoNumber : This field is an “automatic” counter that
assigns a number each time you put data into a new field.
Value Sets (Domains) of Attributes.

• Each simple attribute of an entity type is associated


with a value set (or domain of values), which
specifies the set of values that may be assigned to
that attribute for each individual entity.
Guidelines for naming attributes

❑Guidelines for naming attributes:


–Should be a noun and capitalize the first letter of each word.
(Example: Student_ID.)
–An attribute name should be unique
–To make an attribute name unique and clear, each
attribute name should follow a standard format
–Similar attributes of different entity types should use
similar but distinguishing names.
Criteria for selecting attributes

• Choose a candidate key that will not change its value.


• Choose a candidate key that has valid values and not
be null.
Guidelines for naming and defining
entities
An entity type name is a singular noun
–An entity type should be descriptive and specific
–An entity name should be concise
–Event entity types should be named for the result of
the event, not the activity or process of the event.
Example of domain definitions
Keys

❑Candidate Key
▪ The minimal set of attributes that uniquely identifies
each occurrence of an entity type
▪ A candidate key is the minimal number of attributes,
whose value(s) uniquely identify each entity
occurrence. For example, the branch number
(branchNo) attribute is the candidate key for the
Branch entity type, and has a distinct value for each
branch entity occurrence
Keys

• The candidate key must hold values that are unique


for every occurrence of an entity type.
• This implies that a candidate key cannot contain a
null.
• For example, each branch has a unique branch
number (for example, B003), and there will never be
more than one branch with the same branch number.
keys
❑ Primary Key
▪ The candidate key that is selected to uniquely identify
each occurrence of an entity type. An entity type may
have more than one candidate key.
▪ Eg. consider that a member of staff has a unique
company-defined staff number (staffNo) and also a
unique National Insurance Number (NIN) that is
used by the government. We therefore have two
candidate keys for the Staff entity, one of which
must be selected as the primary key.
Keys

• The choice of primary key for an entity is based on


considerations of attribute length, the minimal
number of attributes required, and the future
certainty of uniqueness. For example, the company-
defined staff number contains a maximum of five
characters (for example, SG14), and the NIN
contains a maximum of nine characters (for example,
WL220658D). Therefore, we select staffNo as the
primary key of the Staff entity type and NIN is then
referred to as the alternate key.
Keys
❑Composite Key
• A candidate key that consists of two or more
attributes
• In some cases, the key of an entity type is composed
of several attributes whose values together are
unique for each entity occurrence but not separately.
For example, consider an entity called Advert with
propertyNo (property number), newspaperName,
dateAdvert, and cost attributes.
Keys

• Many properties are advertised in many newspapers


on a given date. To uniquely identify each occurrence
of the Advert entity type requires values for the
propertyNo, newspaperName, and dateAdvert
attributes.
• Thus, the Advert entity type has a composite primary
key made up of the propertyNo, newspaperName,
and dateAdvert attributes.
RELATIONSHIPS AND RELATIONSHIP
SETS

• A relationship is an association among two or


more entities. E.g employee works in a department.
• Works-in is a relationship between employee and a
department.
• A relationship set is the set of similar relationships.
• It is represented by a diamond, with lines to each of
the entity sets involved
Examples of Relationships

Person belongs Location

Student enrolls Subject(s)

Faculty teaches Subject(s)


Relationship features

❑ Cardinality
▪ Entity instance’s participation count
▪ Describes how many entity instance can be in the
relationship
Cardinality

❖Maximum cardinality (type of relationship)


Describes the maximum number of entity instances
that participate in a relationship
✓ One-to-one
✓ One-to-many
✓ Many-to-many
Cardinality

❖Minimum cardinality
Describes the minimum number of entity instances that
must participate in a relationship
One-to-One Relationship

❑One-to-One (1:1)
A single entity instance in one entity class is related to a
single entity instance in another entity class
Notation

A governor governs (only) one state; a state has (only) one governor
One-to-Many Relationship

❑One-to-Many (1:N)
A single entity instance in one entity class (parent) is
related to multiple entity instances in another entity
class (child) Notation

A book is published by (only) one publisher; a publisher can publish many


(multiple) books
Many-to-Many Relationship

❑Many-to-Many (N:M)
Each entity instance in one entity class is related to
multiple entity instances in another entity class; and vice
versa Notation

A book can be written by many (multiple) authors; an author can write


many (multiple) books
Degree of Relationship

• Degree of ✓Unary (one entity)


relationship: describes ✓Binary (two entities)
the number of entities
involved in a ✓ Ternary (three
relationship entities)
Unary Relationship

❑Unary Relationship Is_married_to


▪ Relationship between
the instances of one
entity type
▪ Unary (recursive): only
PERSON
1 entity
Unary Relationship

Manages

EMPLOYEE
Binary Relationship

• Relationship
between the Is_assigned PARKING
EMPLOYEE
instances of two SPACE
entity type.
• Binary (two
entities)
relationship is most Contains
common PRODUCT
PRODUCTS
LINE
Ternary Relationship

• A simultaneous
relationship among PART
instances of three entity
types

VENDOR WAREHOUSE
Supplies
Starting an ERD

1. Define the Entities.


2. Define the Relationships.
3. Add attributes to the relationships.
4. Add cardinality to the relationships.
5. Don’t forget to use proper naming conventions and
symbol representation.
Example of E/R diagram
empid name dname
did

Works_
employee department
in
Questions or Comments over ERD?
Examples

 Draw the ERD for the following scenarios:


•A player plays for a team.
•Each patient has one or more patient histories; each
instance of patient history belongs to one patient.
•An employee may be recorded as having many jobs; a
particular job may be recorded as having been held by
many employees.
• A person is a citizen of a country.
• A customer may place many orders; an order is specific to
one customer
END

You might also like