Lecture 2 database management system.pdf

samerelking3 9 views 50 slides Mar 08, 2025
Slide 1
Slide 1 of 50
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49
Slide 50
50

About This Presentation

Lecture 2 database in Nile University


Slide Content

Lecture2:
Modeling Data in the Organization
CSCI305
Database Systems
Course Instructors: / Dr. Amira Gaber

define each of the following key terms:, entity relationship model (E-R model), entity-relati
onship diagram (E-R diagram), entity, entity type, entity instance, strong entity type, weak
entity type, identifying relationship, attribute, composite attribute, simple attribute, multivalu
ed attribute, derived attribute, identifier, composite identifier, relationship type, relationship
instance, associative entity ,degree , unary relationship, binary relationship, ternary
relationship, cardinality constraint, minimum cardinality, maximum cardinality.
Write good names and definitions for entities.
Distinguish unary, binary, and ternary relationships and give a common example of each.
Model each of the following constructs in an E-R diagram: composite attribute, multivalue
d attribute, derived tribute, associative entity, identifying relationship, and minimum and
maximum cardinality constraints.
Draw an E-R diagram to represent common business situations.

analysis
design

conceptual data model
➢Conceptual Data Modelis an organized view of database concepts
and their relationships
➢a conceptual data model, a representation of the structure and
constraints of a database
➢conceptual data model is independent of software (such as a database
management system).
➢The Entity-relationship model (E-R model) is used to construct
a conceptual data model,
➢Entity-relationship diagram (E-R diagram, or ERD)
A graphical representation of an entity-relationship model

Sample E-R Diagram

E-R Model Constructs
Entity
•person, place, object,
event, concept
•Example : student,
course
Attribute
•property or
characteristic of an
entity type
•Example :student_name
, course ID
Relationship
•link between entities
•Example Student assign
course
Chen
notation
Crow foot
notation

Basic E-R Notation
Entity
symbols
Relationship
symbols
Attribute
symbols
A special entity
that is also a
relationship

Entity
An entity is a person, a place, an object, an event, or a concept in the
user environment about which the organization wishes to maintain data
Person:EMPLOYEE, STUDENT, PATIENT
Place:STORE, WAREHOUSE, STATE
Object:MACHINE, BUILDING, AUTOMOBILE
Event:SALE, REGISTRATION, RENEWAL
Concept: ACCOUNT, COURSE, WORK CENTER
To find entities,
simply look for nouns in your business analysis …

ENTITY TYPE VERSUS ENTITY INSTANCE
An entity type is a collection of entities that share common properties or
characteristics. Each entity type in an E-R model is given a name.
An entity instance is a single occurrence of an entity type.
entity type entity instance

What Should an Entity Be?
SHOULD BE:
–An object that will have many instances in the database
–An object that will be composed of multiple attributes
–An object that we are trying to model
SHOULD NOT BE:
–A userof the database system
–An outputof the database system (e.g. a report)

What Should an Entity Be?(cont.)
Inappropriate entities
System user System output
Appropriate entities
database needed for a college
sorority’s expense system. the
sorority treasurer manages
accounts, receives expense
reports, and records expense
transactions against each account

STRONG VERSUS WEAK ENTITY TYPES
A strong entity type is one that exists independently of other entity types. (S
ome data modeling software, in fact, use the term independent entity.)
Examples include STUDENT, EMPLOYEE, AUTOMOBILE, and COURSE.
Weak entity type is an entity type whose existence depends on some other
entity type.
Examples :
Employee and its dependents (Parents, Children, Spouse)
Dependent Employee

NAMING AND DEFINING ENTITY TYPES
special guidelines for naming entity types,
➢An entity type name is a singular noun (CUSTOMER, STUDENT)
➢An entity type name should be specific to the organization
▪CUSTOMER in one organization and CLIENTof another
▪a PURCHASE ORDER for orders placed with suppliers is distinct from
CUSTOMER ORDER for orders placed with us by our customers. Both of these
entity types cannot be named ORDER
➢An entity type name should be concise, using as few words as possible
➢Event entity types should be named for the result of the event, not the activity or
process of the event
➢The nameused for the same entity type should be the same on all E-R diagrams on
which the entity type appears

Attributes
➢An attributeis a descriptive property or characteristic of an entity.
Synonyms include element, property, and field
➢Elementarypiece of information about an entity
➢To find attributes, simply look for descriptive nouns that won’t be used as entities
and/or adjectives in your business analysis
➢Each entity will generally have several to many attributes
Examples:
–STUDENT: Student ID, Student Name, Home Address, Phone Number.
–AUTOMOBILE :Vehicle ID, Color, Weight, Horsepower
–EMPLOYEE :Employee ID, Employee Name, Employee Address, Skills

An Entity Relationship Diagram (ERD)(example)
Student
ID Name
Phone
number
Address
Automobile
ID color
Weight
Student
ID
Name
Address
phone
Automobile
ID
color
weight

Identifiers (Keys)
Identifier(Key) -An attribute (or combination of attributes
) that uniquely identifies individual instances of an entity
type
SimpleKey versus CompositeKey
Candidate Key –an attribute that could be a key…
satisfies the requirements for being a key

Characteristics of Identifiers
➢Will not change in value
➢Will not be null
➢No intelligent identifiers (e.g. containing locations or people that might
change)
➢Substitute new, simple keys for long, composite keys

Classification of Attributes
–Simpleversus CompositeAttribute
–Single-Valuedversus MultivaluedAttribute
–Storedversus DerivedAttributes
–IdentifierAttributes

Simple attribute
Simple attribute− Simple attributes are atomic values, which cannot be divided
further. For example, a student's phone number is an atomic value of 10 digits.
weight
Simple attribute

A composite attribute
An attribute broken
into component parts
Compositeattribute−Compositeattributesaremadeofmorethanonesimpleattribute.Forexample,astudent's
completenamemayhavefirst_nameandlast_name,studentaddress

Simple key attribute
The key is underlined

Composite key attribute
The key is composed
of two subparts

a multivalued attribute and derived attribute
Derived
from date employed and
current date
What’s wrong with this?
Multivalued:
an employee can have
more than one skill

attribute that is both multivalued and composite

Relationships
How entities depend on each other in terms of why the
entities depend on each other (the relationship) and what
that relationship is (the cardinality of the relationship).
➢Relationshipsare the associations between the entities
➢Cardinality:it defines the possible number of occurrences
in one entity which is associated with the number of occurre
nces in another
person project
Assigned
Relationship Types

Degree of Relationships
Degree of a Relationship is the number of entity typesthat participate in it
–UnaryRelationship :One entity related to another of the same entity
type
–BinaryRelationship: Entities of two different types related to each
other
–TernaryRelationship: Entities of three different types related
to each other

Cardinality of Relationships
One –to –One
–Each entity in the relationship will have exactly one related entity
One –to –Many
–An entity on one side of the relationship can have many related entities,
but an entity on the other side will have a maximum of one related entity
Many –to –Many
–Entities on both sides of the relationship can have many related entities
on the other side

Cardinality Constraints
Cardinality Constraints -the number of instances of one entity that can or m
ust be associated with each instance of another entity.
Minimum Cardinality
–If zero, then optional
–If one or more, then mandatory
Maximum Cardinality
–The maximum number

Unary relationships
manager
employee
Optional cardinalities with unary degree (one-to one)
wife
Husband

Examples of binary Relationships
and Their Cardinalities
customer order
Student Instructor
artist song
Student
courses
employee
Parking space

Example:Ternary relationships
Note: a relationship can have attributes of its own

Break
test your self

Entity Relationship Diagram Example:
•In a university, a Student enrolls in Courses. A student must be
assigned to at least one or more Courses.
•Each course may be assigned by one or more student
•Each course is taught by a single Professor.
•To maintain instruction quality, a Professor can deliver only one course
•Step 1) Entity Identification
•Step 2) Relationship Identification
•Step 3) Cardinality Identification
•Step 4) Identify Attributes(if there exist)

Entity Relationship Diagram Example:
Step 1) Entity Identification
We have three entities
•Student
•Course
•Professor
Student Course professor
Step 1) Entity Identification
In a university, a Student
enrolls in Courses.A student
must be assigned to at least
one or more Courses. Each
course is taught by a single
Professor. To maintain
instruction quality, a Professor
can deliver only one course

Entity Relationship Diagram Example:
Step 2) Relationship Identification
We have the following two relationships
•The student isassigneda course
•Professordeliversa course
Student Course professor
assigned delivers
In a university, a Student
enrolls in Courses. A student
must be assignedto at least
one or more Courses. Each
course is taught by a single
Professor. To maintain
instruction quality, a Professor
can deliver only one course

Entity Relationship Diagram Example:
Step 3) Cardinality Identification
•A student can be assignedmultiplecourses
•A Professor can deliver onlyonecourse
Student Course professor
assigned delivers
In a university, a Student enrolls in
Courses. A studentmust be assigned to
at least one or moreCourses. Each course
is taught by a single Professor. To
maintain instruction quality, a Professor
can deliver only one course

More on Relationships
Relationship Types vs. Relationship Instances
◦The relationship type is modeled as the diamond and lines between entity types…the
instance is between specific entity instances
Relationships can have attributes
◦These describe features pertaining to the association between the entities in the
relationship
Two entities can have more than one type of relationship between them (multiple
relationships)
Associative Entity = combination of relationship and entity
◦More on this later

Relationship Types vs. Relationship Instances
Relationship Types
Entity and Relationship
instances

Relationship with attributes
Here, the date completed attribute pertains specifically to the employee’s
completion of a course…it is an attribute of the relationship

Relationship with attributes(cont.)
Representing a bill-of -materials structure

Examples of multiple relationships
entities can be related to one another in more than one way

max cardinality constraint

Strong vs. Weak Entities, and
Identifying Relationships
Strong entities
–exist independentlyof other types of entities
–has its own unique identifier
–represented with single-linerectangle
Weak entity
–dependent on a strong entity…cannot exist on its own
–Does not have a unique identifier
–represented with double-linerectangle
Identifying relationship
–links strong entities to weak entities
–represented with double line diamond

Strong vs. Weak Entities, and
Identifying Relationships(cont.)
Strong entity Weak entityIdentifying relationship

Multivalued attribute vs. relationship.
Alternative approaches

Associative Entities
It’s an entity–it has attributes,AND it’s a relationship–it links entities together
How do you know whether to convert a relationship to an associative entity type?
1.All the relationships for the participating entity types are “many” relationships.
2.The resulting associative entity type has independent meaning to end users and,
preferably, can be identified with a single-attribute identifier.
3.The associative entity has one or more attributes in addition to the identifier.
4.The associative entity participates in one or more relationships independent of the
entities related in the associated relationship.
Ternary relationships are converted to associative entities

Associative Entities(cont.)
Associative entity involves a rectangle with a diamond inside.
Note that the many-to-many cardinality symbols face toward the
associative entity and not toward the other entities

Associative Entities(cont.)
This could just be a relationship
with attributes… it’s a judgment call

Associative Entities(cont.)
1)many vendor can supply many parts
to any number of warehouse
2) each part can be supplied by any
number of vendors to more than one
warehouse, but each part must be
supplied by at least one vendor to
a warehouse
3) each warehouse can by supplied with
any number of parts from more than
one vendor, but each warehouse
must be supplied with at least one part