0% found this document useful (0 votes)
93 views

Lecture 1 - DB Concepts and ER Model

Uploaded by

vynnd51098
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)
93 views

Lecture 1 - DB Concepts and ER Model

Uploaded by

vynnd51098
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/ 35

DATABASE CONCEPTS &

ER MODEL
Instructor:

09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 1


Learning Goals

By the end of this lecture students Understand an overview of the basic RDBMS
Concepts
should be able to:

Understand an insight into the architecture and


components of a Database System.

Describe how entities, attributes and relationships


are used to model data;

Converting ER Model to relational schema

09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use


2
Table of contents
◊ SQL Overview SQL Overview
◊ The Relational Database
◊ RDBMS Concepts
◊ ER Model

09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 3


Section 1

SQL OVERVIEW

09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 4


What is SQL?

Structured
Query
Language
➢ Which is a computer language for:
✓ storing,
✓ manipulating and
✓ retrieving data stored in relational database.
➢ SQL is the standard language for Relation Database System, like MySQL, MS
Access, Oracle, Sybase, Informix, Postgres and SQL Server use SQL as
standard database language.
➢ SQL is an ANSI (American National Standards Institute) standard.
5
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
SQL Process

Query Language
SQL Query Parser + Opimizer
Processor

File Manager
DBMS Engine +
Transaction manager

Physical Database

09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 6


SQL Commands
SQL consists of three components:
➢ Data Definition Language (DDL)

➢ Data Manipulation Language (DML) and

➢ Data Control Language (DCL)

7
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Section 2

THE RELATIONAL DATABASE

09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 8


Relational Database Concepts (1/3)
➢ “A DBMS that manages data as collection of tables in which all data
relationships are represented by common values in related tables.”
➢ “A DBMS that follows all the twelve rules of CODD is called RDBMS”

09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 9


Relational Database Concepts (2/3)

Table
Field

CD_ID Title Artist Genre


1 The Wall Pink Floyd Rock
Record 2 Blue Train John Coltrane Jazz
3 Requiem W.A. Mozart Classical

10
Relational Database Concepts (3/3)
Primary
Supplier Key Domain Domain

SCode SName Quantity City

S1 Kamran 20 Lahore

S2 Zafar 10 Islamabad
Row/
Record
S3 Azmat 40 Karachi Cardinality

S4 Abdul 34 Lahore

S5 Nasir 25 Islamabad

Field
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 11
Schema (1/2)
The name of a relation and the set of attributes for a relation is called a
schema.
– Example: the schema for previous slide is
Supplier (SCode, SName, Quantity, City)
Relation schema = name(attributes) + other structure info., e.g., keys,
other constraints.
Order of attributes is arbitrary, but in practice we need to assume the
(standard) order given in the relation schema.
Relational database schema = collection of relation schemas.

09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 12


Schema (2/2)
➢ Relation schema example:

09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 13


Schema versus Instance
Student(studno,name,address)
Course(courseno,lecturer)
Schema
Student(123,Bloggs,Woolton)
(321,Jones,Owens) Instance

sid Name Login age GPA


53666 Jones Jones@ca 18 3.4
53444 smith Smith@ecs 18 3.2
53777 Blake Blake@aa 19 3.8

➔ Cardinality = 3, arity = 5 , all rows distinct


➔ Do all values in each column of a relation instance have to be distinct?

09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 14


What is RDBMS?
➢ RDBMS stands for:

Relational Database Management System


➢ RDBMS is the basis for SQL, and for all modern database systems like:
✓ MS SQL Server,

✓ IBM DB2,

✓ Oracle,

✓ MySQL,

✓ and Microsoft Access.

➢ A Relational database management system (RDBMS) is a database


management system (DBMS) that is based on the relational model as
introduced by E. F. Codd.
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 15
DBMS vs. RDBMS
DBMS RDBMS
The concepts of relationships is It is based on the concept
missing in a DBMS. If it exits it is
very less. Of relationships

Speed of operation is very slow Speed of operation is very Fast


Hardware and Software Hardware and Software
requirements are minimum requirements are High
Platform used is normally DOS Platform used can be any DOS,
UNIX,VAX,VMS, etc
Uses concept of a file Uses concept of table

DBMS normally use 3GL RDBMS normally use a 4GL

Examples are dBase, FOXBASE, etc Examples are ORACLE, INGRESS,


SQL Server 2000 etc
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 16
Section 3

ER MODEL

09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 17


Design Process
Real
world ▪ Survey
Requirement ▪ Interview
collection & ▪ Collect requirement
Analysis ▪ Analisys

▪ Specification Requirement
database

Conceptual ▪ Modelling
design ▪ Design

Conceptual
▪ ER Modelling
model

……..

09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 18


Basic E-R Notation

Entity
A special entity
symbols that is also a
relationship

Relationship Attribute
symbols symbols

09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 19


ER Model Overview
Sample E-R Diagram

09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 20


Cardinality of Relationships (1/2)
➢ One – to – one:

EMPLOYEE DEPARTMENT

➢ One – to – many:

DEPARTMENT EMPLOYEE

21
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Cardinality of Relationships (2/2)
➢ Many – to – many:

EMPLOYEE PROJECT

❖ In which:

09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 22


Binary relationships

09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 23


Converting ER Model to relational schema
Rule 1 - Convert entity type with simple attributes

CUSTOMER entity type with simple attributes

CUSTOMER relation

09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 24


Converting ER Model to relational schema
Rule 2 - Convert Multivalue attribute

Multivalued attribute becomes a separate relation with foreign key

1–to–many relationship between original entity and new relation


09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 25
Converting ER Model to relational schema
Rule 3 - Convert Unary relationship one to one

EMPLOYEE entity with Manages relationship

EMPLOYEE relation with recursive foreign key


09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 26
Converting ER Model to relational schema
Rule 4 – Convert binary relationship one to one

09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 27


Converting ER Model to relational schema
Rule 5 – Convert Unary relationship one to many

EMPLOYEE entity with Manages relationship

EMPLOYEE relation with recursive foreign key


09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 28
Converting ER Model to relational schema
Rule 6 – Convert Binary relationship one to many

Note the mandatory one

Again, no null value in the foreign key…this is because of the mandatory minimum cardinality
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 29
Converting ER Model to relational schema
Rule 7 – Convert Unary relationship many to many

Bill-of-materials relationships (M:N)

ITEM and COMPONENT relations


09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 30
Converting ER Model to relational schema
Rule 8 – Convert Binary relationship many to many

The Supplies relationship will need to


become a separate relation

Composite primary key

New intersection relation


Foreign key Foreign key

31
09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use
Converting ER Model to relational schema
Another - Convert Ternary relationship

09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 32


Converting ER Model to relational schema
Another- Convert Ternary relationship (2)

09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 33


Summary

✓ SQL Overview
• SQL, SQL Process, SQL Command
✓ The Relational Database
• Table, Field, Record, Schema
✓ RDBMS Concepts
• RDBMS, RDBMS vs DBMS
✓ ER Model
• Design Process, Notation, Converting ER Model to relational
schema

09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy - Internal Use 34


Thank you

09e-BM/DT/FSOFT - ©FPT SOFTWARE – Fresher Academy -


35
Internal Use

You might also like