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

19BNA502B - Data Management - 16 - 18

The document outlines a course on Data Management led by Ms. Shilpa R.G. and covers topics such as database design using the Entity-Relationship (ER) model, relational database design, and application development. It details the phases of database design, common pitfalls, and the representation of entity and relationship sets in ER diagrams. Additionally, it discusses the differences between ER diagrams and UML class diagrams, as well as the importance of semi-structured data in application design.

Uploaded by

Janardhan M K
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 views38 pages

19BNA502B - Data Management - 16 - 18

The document outlines a course on Data Management led by Ms. Shilpa R.G. and covers topics such as database design using the Entity-Relationship (ER) model, relational database design, and application development. It details the phases of database design, common pitfalls, and the representation of entity and relationship sets in ER diagrams. Additionally, it discusses the differences between ER diagrams and UML class diagrams, as well as the importance of semi-structured data in application design.

Uploaded by

Janardhan M K
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/ 38

Course Code: 19BNA502B

Course Title: Data Management

Course Leader:
Ms. Shilpa R.G.

Email: [email protected]

1
Faculty of Management and Commerce © Ramaiah University of Applied Sciences
Course Code: 19BNA502A

Course Title: Data Management


Session 16-18: Database Design

Course Leader:

Ms. Shilpa R.G.


[email protected]
2
Faculty of Management and Commerce © Ramaiah University of Applied Sciences
Session Objectives

At the end of this session, student will be able to:


• Discuss Database design using ER-Model

• Discuss Entity-Relationship Model

• Discuss Relational Database design

3
Faculty of Management and Commerce © Ramaiah University of Applied Sciences
Session Contents
• Database design using ER-Model

• The Entity-Relationship Model

• Relational Database design

• Application design and development

4
Faculty of Management and Commerce © Ramaiah University of Applied Sciences
Design Phases
• Initial phase -- Characterize fully the data needs of the
prospective database users.

• Second phase -- choosing a data model

– Applying the concepts of the chosen data model

– Translating these requirements into a conceptual


schema of the database.

– A fully developed conceptual schema indicates the


functional requirements of the enterprise.

• Describe the kinds of operations (or transactions)


that will be performed on the data. 5
Faculty of Management and Commerce © Ramaiah University of Applied Sciences
Design Phases contd…
 Final Phase -- Moving from an abstract data model to the
implementation of the database

– Logical Design – Deciding on the database schema.

• Database design requires that we find a “good” collection of


relation schemas.

 Business decision – What attributes should we record in the


database?

 Computer Science decision – What relation schemas should


we have and how should the attributes be distributed
among the various relation schemas?

– Physical Design – Deciding on the physical layout of the


database 6
Faculty
©M. S. of Management
Ramaiah andofCommerce
University Applied Sciences © Ramaiah University of Applied Sciences
Design Alternatives
 In designing a database schema, we must ensure that we avoid
two major pitfalls:

• Redundancy: a bad design may result in repeat information.


 Redundant representation of information may lead to data
inconsistency among the various copies of information

• Incompleteness: a bad design may make certain aspects of the


enterprise difficult or impossible to model.

 Avoiding bad designs is not enough. There may be a large number


of good designs from which we must choose.

7
Faculty
©M. S. of Management
Ramaiah andofCommerce
University Applied Sciences © Ramaiah University of Applied Sciences
Design Approaches

 Entity Relationship Model

• Models an enterprise as a collection of entities and relationships


 Entity: a “thing” or “object” in the enterprise that is
distinguishable from other objects

• Described by a set of attributes

 Relationship: an association among several entities

• Represented diagrammatically by an entity-relationship diagram:


 Normalization Theory

• Formalize what designs are bad, and test for them

8
Faculty
©M. S. of Management
Ramaiah andofCommerce
University Applied Sciences © Ramaiah University of Applied Sciences
ER model -- Database Modeling

• The ER data mode was developed to facilitate database


design by allowing specification of an enterprise schema
that represents the overall logical structure of a
database.
• The ER data model employs three basic concepts:
– entity sets,
– relationship sets,
– attributes.
• The ER model also has an associated diagrammatic
representation, the ER diagram, which can express the
overall logical structure of a database graphically.

9
Faculty of Management and Commerce © Ramaiah University of Applied Sciences
Entity Sets
• An entity is an object that exists and is distinguishable from other objects.

– Example: specific person, company, event, plant

• An entity set is a set of entities of the same type that share the same
properties.

– Example: set of all persons, companies, trees, holidays

• An entity is represented by a set of attributes; i.e., descriptive properties


possessed by all members of an entity set.

– Example:

instructor = (ID, name, salary )


course= (course_id, title, credits)

• A subset of the attributes form a primary key of the entity set; i.e.,
uniquely identifying each member of the set.

10
Faculty of Management and Commerce © Ramaiah University of Applied Sciences
Entity Sets -- instructor and student

11
Faculty of Management and Commerce © Ramaiah University of Applied Sciences
Representing Entity sets in ER Diagram

 Entity sets can be represented graphically as follows:


• Rectangles represent entity sets.
• Attributes listed inside entity rectangle
• Underline indicates primary key attributes

12
Faculty of Management and Commerce © Ramaiah University of Applied Sciences
Representing Relationship Sets via ER Diagrams

 Diamonds represent relationship sets.

13
Faculty of Management and Commerce © Ramaiah University of Applied Sciences
Relationship Sets contd…
• An attribute can also be associated with a relationship set.
• For instance, the advisor relationship set between entity sets instructor and
student may have the attribute date which tracks when the student started
being associated with the advisor

76766 Crick 98988 Tanaka


45565 Katz 3 May 2008 12345 Shankar
10 June 2007
10101 Srinivasan 00128 Zhang
12 June 2006

98345 Kim 6 June 2009 76543 Brown


76543 Singh 30 June 2007
76653 Aoi
31 May 2007
22222 Einstein 23121 Chavez
4 May 2006

instructor 44553 Peltier

student

14
Faculty of Management and Commerce © Ramaiah University of Applied Sciences
Relationship Sets with Attributes

15
Faculty of Management and Commerce © Ramaiah University of Applied Sciences
Roles
• Entity sets of a relationship need not be distinct
– Each occurrence of an entity set plays a “role” in the relationship
• The labels “course_id” and “prereq_id” are called roles.

16
Faculty of Management and Commerce © Ramaiah University of Applied Sciences
Degree of a Relationship Set
• Binary relationship

– involve two entity sets (or degree two).

– most relationship sets in a database system are binary.

• Relationships between more than two entity sets are rare. Most
relationships are binary. (More on this later.)

– Example: students work on research projects under the


guidance of an instructor.

– relationship proj_guide is a ternary relationship between


instructor, student, and project

17
Faculty of Management and Commerce © Ramaiah University of Applied Sciences
Non-binary Relationship Sets

• Most relationship sets are binary

• There are occasions when it is more convenient to represent


relationships as non-binary.

• E-R Diagram with a Ternary Relationship

18
Faculty of Management and Commerce © Ramaiah University of Applied Sciences
Representing Cardinality Constraints in ER Diagram
• We express cardinality constraints by drawing either a directed line (),
signifying “one,” or an undirected line (—), signifying “many,” between the
relationship set and the entity set.

• One-to-one relationship between an instructor and a student :

– A student is associated with at most one instructor via the relationship


advisor

– A student is associated with at most one department via stud_dept

19
Faculty of Management and Commerce © Ramaiah University of Applied Sciences
One-to-Many Relationship

• one-to-many relationship between an instructor and a student


– an instructor is associated with several (including 0) students via
advisor
– a student is associated with at most one instructor via advisor,

20
Faculty of Management and Commerce © Ramaiah University of Applied Sciences
Many-to-One Relationships

• In a many-to-one relationship between an instructor and a student,

– an instructor is associated with at most one student via advisor,

– and a student is associated with several (including 0) instructors


via advisor

21
Faculty of Management and Commerce © Ramaiah University of Applied Sciences
Many-to-Many Relationship
• An instructor is associated with several (possibly 0) students via advisor

• A student is associated with several (possibly 0) instructors via advisor

22
Faculty of Management and Commerce © Ramaiah University of Applied Sciences
E-R Diagram for a University Enterprise

23
Faculty of Management and Commerce © Ramaiah University of Applied Sciences
Design Issues

24
Faculty of Management and Commerce © Ramaiah University of Applied Sciences
Common Mistakes in E-R Diagrams
 Example of erroneous E-R diagrams

25
Faculty
©M. S. of Management
Ramaiah andofCommerce
University Applied Sciences © Ramaiah University of Applied Sciences
Common Mistakes in E-R Diagrams (Cont.)

26
Faculty
©M. S. of Management
Ramaiah andofCommerce
University Applied Sciences © Ramaiah University of Applied Sciences
Entities vs. Attributes
 Use of entity sets vs. attributes

 Use of phone as an entity allows extra information about phone numbers


(plus multiple phone numbers)

27
Faculty
©M. S. of Management
Ramaiah andofCommerce
University Applied Sciences © Ramaiah University of Applied Sciences
Entities vs. Relationship sets
 Use of entity sets vs. relationship sets
Possible guideline is to designate a relationship set to describe
an action that occurs between entities

• Placement of relationship attributes

For example, attribute date as attribute of advisor or as attribute


of student

28
Faculty
©M. S. of Management
Ramaiah andofCommerce
University Applied Sciences © Ramaiah University of Applied Sciences
Summary of Symbols Used in E-R Notation

29
Faculty of Management and Commerce © Ramaiah University of Applied Sciences
Symbols Used in E-R Notation contd…

30
Faculty of Management and Commerce © Ramaiah University of Applied Sciences
Alternative ER Notations

31
Faculty of Management and Commerce © Ramaiah University of Applied Sciences
UML

• UML: Unified Modeling Language

• UML has many components to graphically model


different aspects of an entire software system

• UML Class Diagrams correspond to E-R Diagram,


but several differences.

32
Faculty of Management and Commerce © Ramaiah University of Applied Sciences
ER vs. UML Class Diagrams

* Note reversal of position in cardinality constraint depiction

33
Faculty of Management and Commerce © Ramaiah University of Applied Sciences
UML Class Diagrams contd…
• Binary relationship sets are represented in UML by just drawing
a line connecting the entity sets. The relationship set name is
written adjacent to the line.

• The role played by an entity set in a relationship set may also be


specified by writing the role name on the line, adjacent to the
entity set.

• The relationship set name may alternatively be written in a box,


along with attributes of the relationship set, and the box is
connected, using a dotted line, to the line depicting the
relationship set. 34
Faculty of Management and Commerce © Ramaiah University of Applied Sciences
Other Aspects of Database Design

• Functional Requirements

• Data Flow, Workflow

• Schema Evolution

35
Faculty of Management and Commerce © Ramaiah University of Applied Sciences
Application Design and Development
• Binary relationship sets are represented in UML by just drawing
a line connecting the entity sets. The relationship set name is
written adjacent to the line.

• The role played by an entity set in a relationship set may also be


specified by writing the role name on the line, adjacent to the
entity set.

• The relationship set name may alternatively be written in a box,


along with attributes of the relationship set, and the box is
connected, using a dotted line, to the line depicting the
relationship set. 36
Faculty of Management and Commerce © Ramaiah University of Applied Sciences
Application Design and Development

Semi-Structured Data

• Many applications require storage of complex data, whose


schema changes often
• The relational model’s requirement of atomic data types may
be an overkill
– E.g., storing set of interests as a set-valued attribute of a
user profile may be simpler than normalizing it

37
Faculty of Management and Commerce © Ramaiah University of Applied Sciences
Application Design and Development

Semi-Structured Data

• Data exchange can benefit greatly from semi-structured data


– Exchange can be between applications, or between back-end and front-
end of an application
– Web-services are widely used today, with complex data fetched to the
front-end and displayed using a mobile app or JavaScript
• JSON and XML are widely used semi-structured data models

38
Faculty of Management and Commerce © Ramaiah University of Applied Sciences

You might also like