0% found this document useful (0 votes)
3 views74 pages

DB 02 TP

The document outlines the concepts of database design using the Entity-Relationship (ER) model, including entity types, attributes, relationships, and structural constraints. It provides a sample database application for a COMPANY, detailing the design process and considerations for refining the ER design. Additionally, it includes a problem statement for designing a university database schema with specific requirements for entities and their relationships.

Uploaded by

komeil0serhan
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)
3 views74 pages

DB 02 TP

The document outlines the concepts of database design using the Entity-Relationship (ER) model, including entity types, attributes, relationships, and structural constraints. It provides a sample database application for a COMPANY, detailing the design process and considerations for refining the ER design. Additionally, it includes a problem statement for designing a university database schema with specific requirements for entities and their relationships.

Uploaded by

komeil0serhan
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/ 74

Introduction to Database TP 02

Dr Mohamad AOUDE
December 3, 2024
LU

1 Dr Mohamad AOUDE
Outline
Chapter 2 Outline

ˆ Using High-Level Conceptual Data Models for Database Design


ˆ A Sample Database Application
ˆ Entity Types, Entity Sets, Attributes, and Keys
ˆ Relationship Types, Relationship Sets, Roles, and Structural
Constraints
ˆ Weak Entity Types

2 Dr Mohamad AOUDE
Chapter 2 Outline (cont’d.)

ˆ Refining the ER Design for the COMPANY Database


ˆ ER Diagrams, Naming Conventions, and Design Issues
ˆ Example of Other Notation: UML Class Diagrams
ˆ Relationship Types of Degree Higher than Two

3 Dr Mohamad AOUDE
Data Modeling Using the
Entity-Relationship (ER) Model
Data Modeling Using the Entity-Relationship (ER) Model

ˆ Entity-Relationship (ER) model


ˆ Popular high-level conceptual data model
ˆ ER diagrams
ˆ Diagrammatic notation associated with the ER model
ˆ Unified Modeling Language (UML)

4 Dr Mohamad AOUDE
Using High-Level Conceptual
Data Models for Database
Design
Using High-Level Conceptual Data Models for Database Design

ˆ Requirements collection and analysis


ˆ Database designers interview prospective database users to
understand and document data requirements
ˆ Result: data requirements
ˆ Functional requirements of the application

5 Dr Mohamad AOUDE
Using High-Level Conceptual Data Models (cont’d.)

ˆ Conceptual schema
ˆ Conceptual design
ˆ Description of data requirements
ˆ Includes detailed descriptions of the entity types, relationships, and
constraints
ˆ Transformed from high-level data model into implementation data
model

6 Dr Mohamad AOUDE
Using High-Level Conceptual Data Models (cont’d.)

ˆ Logical design or data model mapping


ˆ Result is a database schema in implementation data model of DBMS
ˆ Physical design phase
ˆ Internal storage structures, file organizations, indexes, access paths,
and physical design parameters for the database files specified

7 Dr Mohamad AOUDE
A Sample Database Application
A Sample Database Application

ˆ COMPANY
ˆ Employees, departments, and projects
ˆ Company is organized into departments
ˆ Department controls a number of projects
ˆ Employee: store each employee’s name, Social Security number,
address, salary, sex (gender), and birth date
ˆ Keep track of the dependents of each employee

8 Dr Mohamad AOUDE
A Sample Database Application

9 Dr Mohamad AOUDE
Entity Types, Entity Sets,
Attributes, and Keys
Entity Types, Entity Sets, Attributes, and Keys

ˆ ER model describes data as:


ˆ Entities
ˆ Relationships
ˆ Attributes

10 Dr Mohamad AOUDE
Entities and Attributes

ˆ Entity
ˆ Thing in real world with independent existence
ˆ Attributes
ˆ Particular properties that describe entity
ˆ Types of attributes:
ˆ Composite versus simple (atomic) attributes
ˆ Single-valued versus multivalued attributes
ˆ Stored versus derived attributes
ˆ NULL values
ˆ Complex attributes

11 Dr Mohamad AOUDE
Entities and Attributes

12 Dr Mohamad AOUDE
Entity Types, Entity Sets, Keys, and Value Sets

13 Dr Mohamad AOUDE
Entity Types, Entity Sets, Keys, and Value Sets

ˆ Entity type
ˆ Collection (or set) of entities that have the same attributes
ˆ Key or uniqueness constraint
ˆ Attributes whose values are distinct for each individual entity in
entity set
ˆ Key attribute
ˆ Uniqueness property must hold for every entity set of the entity type
ˆ Value sets (or domain of values)
ˆ Specifies set of values that may be assigned to that attribute for
each individual entity

14 Dr Mohamad AOUDE
Initial Conceptual Design of the COMPANY Database

15 Dr Mohamad AOUDE
Initial Conceptual Design of the COMPANY Database

16 Dr Mohamad AOUDE
Relationship Types, Relationship
Sets, Roles, and Structural
Constraints
Relationship Types, Relationship Sets, Roles, and Structural
Constraints

ˆ Relationship
ˆ When an attribute of one entity type refers to another entity type
ˆ Represent references as relationships not attributes

17 Dr Mohamad AOUDE
Relationship Types, Sets, and Instances

ˆ Relationship type R among n entity types E1 , E2 , . . . , En


ˆ Defines a set of associations among entities from these entity types
ˆ Relationship instances ri
ˆ Each ri associates n individual entities (e1 , e2 , . . . , en )
ˆ Each entity ej in ri is a member of entity set Ej

18 Dr Mohamad AOUDE
Relationship

19 Dr Mohamad AOUDE
Relationship Degree

ˆ Degree of a relationship type


ˆ Number of participating entity types
ˆ Binary, ternary
ˆ Relationships as attributes
ˆ Think of a binary relationship type in terms of attributes

20 Dr Mohamad AOUDE
Relationship

21 Dr Mohamad AOUDE
Role Names and Recursive Relationships

ˆ Role name signifies role that a participating entity plays in each


relationship instance
ˆ Recursive relationships
ˆ Same entity type participates more than once in a relationship type
in different roles
ˆ Must specify role name

22 Dr Mohamad AOUDE
Constraints on Binary Relationship Types

ˆ Cardinality ratio for a binary relationship


ˆ Specifies maximum number of relationship instances that entity can
participate in
ˆ Participation constraint
ˆ Specifies whether existence of entity depends on its being related to
another entity
ˆ Types: total and partial

23 Dr Mohamad AOUDE
Attributes of Relationship Types

ˆ Attributes of 1:1 or 1:N relationship types can be migrated to one


entity type
ˆ For a 1:N relationship type
ˆ Relationship attribute can be migrated only to entity type on N-side
of relationship
ˆ For M : N relationship types
ˆ Some attributes may be determined by combination of participating
entities
ˆ Must be specified as relationship attributes

24 Dr Mohamad AOUDE
Weak Entity Types
Weak Entity Types

ˆ Do not have key attributes of their own


ˆ Identified by being related to specific entities from another entity
type
ˆ Identifying relationship
ˆ Relates a weak entity type to its owner
ˆ Always has a total participation constraint

25 Dr Mohamad AOUDE
Refining the ER Design for the
COMPANY Database
Refining the ER Design for the COMPANY Database

ˆ Change attributes that represent relationships into relationship types


ˆ Determine cardinality ratio and participation constraint of each
relationship type

26 Dr Mohamad AOUDE
ER Diagrams, Naming
Conventions, and Design Issues
ER Diagrams, Naming Conventions, and Design Issues

27 Dr Mohamad AOUDE
Proper Naming of Schema Constructs

ˆ Choose names that convey meanings attached to different


constructs in schema
ˆ Nouns give rise to entity type names
ˆ Verbs indicate names of relationship types
ˆ Choose binary relationship names to make ER diagram readable
from left to right and from top to bottom

28 Dr Mohamad AOUDE
Design Choices for ER Conceptual Design

ˆ Model concept first as an attribute


ˆ Refined into a relationship if attribute is a reference to another
entity type
ˆ Attribute that exists in several entity types may be elevated to an
independent entity type
ˆ Can also be applied in the inverse

29 Dr Mohamad AOUDE
Alternative Notations for ER
Diagrams
Alternative Notations for ER Diagrams

30 Dr Mohamad AOUDE
Alternative Notations for ER Diagrams

ˆ Specify structural constraints on relationships


ˆ Replaces cardinality ratio (1:1, 1:N, M:N) and single/double line
notation for participation constraints
ˆ Associate a pair of integer numbers (min, max) with each
participation of an entity type E in a relationship type R, where
0 ≤ min ≤ max and max ≥ 1

31 Dr Mohamad AOUDE
Example of Other Notation:
UML Class Diagrams
UML Class Diagrams

32 Dr Mohamad AOUDE
Example of Other Notation: UML Class Diagrams

ˆ UML methodology
ˆ Used extensively in software design
ˆ Many types of diagrams for various software design purposes
ˆ UML class diagrams
ˆ Entity in ER corresponds to an object in UML

33 Dr Mohamad AOUDE
Example of Other Notation: UML Class Diagrams (cont’d.)

ˆ Class includes three sections:


ˆ Top section gives the class name
ˆ Middle section includes the attributes
ˆ Last section includes operations that can be applied to individual
objects

34 Dr Mohamad AOUDE
Relationship Types of Degree
Higher than Two
Relationship Types of Degree Higher than Two

ˆ Degree of a relationship type


ˆ Number of participating entity types
ˆ Binary: relationship type of degree two
ˆ Ternary: relationship type of degree three

35 Dr Mohamad AOUDE
Choosing Between Binary and
Ternary Relationships
Choosing Between Binary and Ternary (or Higher-Degree) Re-
lationships

ˆ Some database design tools permit only binary relationships.


ˆ Ternary relationship must be represented as a weak entity type:
ˆ No partial key and three identifying relationships.
ˆ Represent ternary relationship as a regular entity type:
ˆ By introducing an artificial or surrogate key.

36 Dr Mohamad AOUDE
Constraints on Ternary
Relationships
Constraints on Ternary (or Higher-Degree) Relationships

ˆ Notations for specifying structural constraints on n-ary relationships.


ˆ Should both be used if it is important to fully specify structural
constraints.

37 Dr Mohamad AOUDE
Choosing between Binary and Ternary

38 Dr Mohamad AOUDE
Summary
Summary

ˆ Basic ER model concepts of entities and their attributes


ˆ Different types of attributes
ˆ Structural constraints on relationships
ˆ ER diagrams represent E-R schemas
ˆ UML class diagrams relate to ER modeling concepts

39 Dr Mohamad AOUDE
Problem 1 Statement
Problem 1 Statement

Design an ER schema for a UNIVERSITY database:


(a) The university keeps track of each student’s name, student number,
Social Security number, current address and phone number,
permanent address and phone number, birth date, sex, class
(freshman, sophomore, ..., graduate), major department, minor
department (if any), and degree program (B.A., B.S., ..., Ph.D.).
Some user applications need to refer to the city, state, and ZIP Code
of the student’s permanent address and to the student’s last name.
Both Social Security number and student number have unique
values for each student.
(b) Each department is described by a name, department code, office
number, office phone number, and college. Both name and code
have unique values for each department.
(c) Each course has a course name, description, course number, number
of semester hours, level, and offering department. The value of the
course number is unique for each course.
40 Dr Mohamad AOUDE
Problem 1 Statement

Design an ER schema for a UNIVERSITY database:


(d) Each section has an instructor, semester, year, course, and section
number. The section number distinguishes sections of the same
course that are taught during the same semester/year; its values are
1, 2, 3, ..., up to the number of sections taught during each
semester.
(e) A grade report has a student, section, letter grade, and numeric
grade (0, 1, 2, 3, or 4).
Task:
ˆ Design an ER schema for this application.
ˆ Draw an ER diagram for the schema.
ˆ Specify key attributes of each entity type, and structural constraints
on each relationship type.
ˆ Note any unspecified requirements, and make appropriate
assumptions to complete the specification.
41 Dr Mohamad AOUDE
Requirements
Requirements Overview

ˆ Student:
ˆ Attributes: Name, Student Number (unique), SSN (unique), Current
Address/Phone, Permanent Address/Phone, Birth Date, Sex, Class,
Major Department, Minor Department (if any), Degree Program.
ˆ Note: Permanent address includes city, state, and ZIP Code.
ˆ Department:
ˆ Attributes: Name (unique), Department Code (unique), Office
Number, Office Phone, College.
ˆ Course:
ˆ Attributes: Course Name, Description, Course Number (unique),
Number of Semester Hours, Level, Offering Department.
ˆ Section:
ˆ Attributes: Instructor, Semester, Year, Course, Section Number.
ˆ Note: Section Number distinguishes sections of the same course in
the same semester/year.
ˆ Grade Report:
ˆ Attributes: Student, Section, Letter Grade, Numeric Grade (0-4).
42 Dr Mohamad AOUDE
ER Schema Design Exercise

Design an ER schema for a university database and draw an ER diagram


for the schema, considering the following specifications:

ˆ Student:
ˆ name (first, last)
ˆ student number (unique)
ˆ Social Security number (unique)
ˆ class (freshman, sophomore, ...)
ˆ major
ˆ degree program (B.A., B.S., ..., Ph.D.)
ˆ permanent address (city, state, ZIP)
ˆ Department:
ˆ name (unique)
ˆ department code (unique)
ˆ office number
ˆ office phone number
ˆ college
43 Dr Mohamad AOUDE
ER Schema Design Exercise

ˆ Course:
ˆ course name
ˆ description
ˆ course number (unique)
ˆ number of semester hours
ˆ level
ˆ offering department
ˆ Section:
ˆ instructor
ˆ semester
ˆ year
ˆ course
ˆ section number (1, 2, 3, ...)
ˆ Grade Report:
ˆ student
ˆ section
ˆ letter grade
ˆ numeric grade (0, 1, 2, 3, or 4)
44 Dr Mohamad AOUDE
ER Diagram
Structural Constraints and Key
Attributes
Structural Constraints and Key Attributes

ˆ Student:
ˆ Key: Student Number (unique), SSN (unique).
ˆ Relationships:
ˆ Belongs to Major Department: Total Participation.
ˆ Enrolled in Section: Total Participation.
ˆ Department:
ˆ Key: Name (unique), Department Code (unique).
ˆ Relationships:
ˆ Offers Course: Total Participation.
ˆ Course:
ˆ Key: Course Number (unique).
ˆ Relationships:
ˆ Offered by Department: Total Participation.
ˆ Taught in Section: Total Participation.
ˆ Section:
ˆ Key: Combination of Course and Section Number.
ˆ Relationships:
ˆ Graded in Grade Report: Total Participation.
45 Dr Mohamad AOUDE
Tasks

1. ER Schema Design: Define the entity types, attributes, and


relationships based on the provided specifications.
2. ER Diagram: Create a visual representation of the ER schema
using standard ER diagram notation.
3. Key Attributes: Identify the primary key for each entity type.
4. Structural Constraints: Specify cardinality ratios (1:1, 1:N, M:N)
and participation constraints (total or partial) for each relationship
type.
5. Assumptions: Clearly state any assumptions made to address
unspecified requirements and ensure a complete schema design.

46 Dr Mohamad AOUDE
Choosing between Binary and Ternary

47 Dr Mohamad AOUDE
STUDENT Table

Course Name Course Number Credit Hours Department


Intro to
Computer Science CS1310 4 CS
Data Structures CS3320 4 CS
Discrete
Mathematics MATH2410 3 MATH
Database CS3380 3 CS

Table 1: Student Table Information

48 Dr Mohamad AOUDE
Course Information
COURSE Table

Section Identifier Course Number Semester Year Instructor


85 MATH2410 Fall 07 King
92 CS1310 Fall 07 Anderson
102 CS3320 Spring 08 Knuth
112 MATH2410 Fall 08 Chang
119 CS1310 Fall 08 Anderson
135 CS3380 Fall 08 Stone

Table 2: Course Table Information

49 Dr Mohamad AOUDE
Section Information
SECTION Table

Student Number Section Identifier Grade


17 112 B
17 119 C
8 85 A
8 92 A
8 102 B
8 135 A

Table 3: Section Table Information

50 Dr Mohamad AOUDE
Grade Report
GRADE REPORT Table

Course Number Prerequisite Number


CS3380 CS3320
CS3380 MATH2410
CS3320 CS1310

Table 4: Grade Report Table Information

51 Dr Mohamad AOUDE
UML

52 Dr Mohamad AOUDE

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy