SlideShare a Scribd company logo
Copyright © 2009, Oracle. All rights reserved.
Introduction
Copyright © 2009, Oracle. All rights reserved.
I - 2
Requirements of an Application:
Copyright © 2009, Oracle. All rights reserved.
I - 3
 Information is a critical factor for any business to be successful.
Information is extracted from data stored in databases.
 Database is an integral part of an organization. Aspiring database
developers should be able to efficiently design and implement
databases.
 Knowledge of these will enable the developers to build robust
database solutions.
 This module will help students to understand the concepts related
to relational databases.
Copyright © 2009, Oracle. All rights reserved.
I - 4
What is a
Database?
Copyright © 2009, Oracle. All rights reserved.
I - 5
 A database is a collection of logically related data.
 Data means known facts, which are meaningful and can be
recorded.
For example:
Hard Disk
Address
Book
Copyright © 2009, Oracle. All rights reserved.
I - 6
 Database Management is the task of maintaining databases so that
the information is easily available.
 Database Management Systems (DBMS) is the software required
to perform the task of maintaining databases.
 Management of data involves:
 Defining structures for data storage.
 Providing methods for data manipulation, such as adding, editing,
and deleting data.
 Providing data security against unauthorized access.
 Database management systems are now available on a wide range
of computers, from desktops to mainframes. The size and power of
the computer determines the system facilities, such as security and
storage.
Copyright © 2009, Oracle. All rights reserved.
I - 7
The main objectives of any DBMS are to:
 Provide an efficient and easy way to store, update, and retrieve data
from a database.
 Manage information about users who interact with the DBMS, and the
tasks that these users can perform on the data.
Today, relational databases are the most popular form of storing
data. Besides storing data and extracting information, a database has
to be managed effectively. The software that is used to manage and
retrieve information in a relational database is called a Relational
Database Management System (RDBMS).
A Relational Database Management System (RDBMS) is an
advanced version of DBMS that also defines the relationship between
various data values.
Copyright © 2009, Oracle. All rights reserved.
I - 8
 Some typical applications of an RDBMS are:
 Airline and railway reservations
 Banking applications
 Manufacturing industry
 Order processing
 Hospital management systems
 Library management systems
 Hotel industry
Copyright © 2009, Oracle. All rights reserved.
I - 9
Several RDBMS products are available today. Some popular products are:
 Oracle
 Microsoft SQL Server
 Sybase
 Ingres
 DB2
Copyright © 2009, Oracle. All rights reserved.
I - 10
Now, let us understand the
working of DBMS.
Copyright © 2009, Oracle. All rights reserved.
I - 11
Database
DBMS
Request for
data
Retrieved data
returned as a result
User system to extract
information from the
database
Copyright © 2009, Oracle. All rights reserved.
I - 12
 Relational data structure:
 Each table in a database has a unique table name.
 The row (or record) in the table is called a tuple.
 The column (or field) is called an attribute.
 Every column in a table must have a unique name.
 The number of tuples is called the cardinality of the table.
 The number of attributes is called the degree of the table.
 Rows are unordered in a relation.
 A column or combination of columns that uniquely identifies each row in
the table is called the primary key of the table.
 A table where every row is different from all other rows is called a relation.
 A domain is a collection of values from which one or more attributes
(columns) draw their actual values.
Copyright © 2009, Oracle. All rights reserved.
I - 13
The following diagram describes the data structure of an RDBMS.
T_CODE NAME AGE SEMESTER
I1001 Nancy Mathews 27 I
I1002 Catherine 38 II
I1003 Mac Thams 50 IV
I1004 Joe Nelson 35 III
Tuple
Copyright © 2009, Oracle. All rights reserved.
I - 14
T_CODE NAME AGE SEMESTER
I1001 Nancy Mathews 27 I
I1002 Catherine 38 II
I1003 Mac Thams 50 IV
I1004 Joe Nelson 35 III
Attributes
The following diagram describes the data structure of an RDBMS.
Copyright © 2009, Oracle. All rights reserved.
I - 15
T_CODE NAME AGE SEMESTER
I1001 Nancy Mathews 27 I
I1002 Catherine 38 II
I1003 Mac Thams 50 IV
I1004 Joe Nelson 35 III
Primary Key
Relation
The following diagram describes the data structure of an RDBMS.
Copyright © 2009, Oracle. All rights reserved.
I - 16
T_CODE NAME AGE SEMESTER
I1001 Nancy Mathews 27 I
I1002 Catherine 38 II
I1003 Mac Thams 50 IV
I1004 Joe Nelson 35 III
DOMAIN
T_CODE
DOMAIN
NAME
DOMAIN
AGE
DOMAIN
SEMESTER
The following diagram describes the data structure of an RDBMS.
Copyright © 2009, Oracle. All rights reserved.
I - 17
 Representing missing information:
 In RDBMS, missing or unknown information is represented as a NULL
value in a table.
 NULL is not the same as space or zero.
 Representing relationships in an RDBMS:
 A column in one table whose value matches the primary key in some
other table is called a foreign key.
 A primary key and a foreign key create a parent-child relationship
between the tables that connect them.
Copyright © 2009, Oracle. All rights reserved.
I - 18
 The ER (Entity-Relationship) model:
Views the real world as a collection of objects or entities and the relationship
among them.
It also has a corresponding diagramming technique.
STUDENT COURSE
LEARN
Sno Sname CrsID Crsname
Entities
Relationship
Attributes Attributes
Copyright © 2009, Oracle. All rights reserved.
I - 19
 An entity:
 Is any object, place, person, or activity about which the data is recorded.
 Can be categorized as entity type and entity instance.
 In the ER model diagramming technique, entities are named and represented
inside a box.
For example:
TEACHER
Copyright © 2009, Oracle. All rights reserved.
I - 20
 Entity can be of the following types:
Dependent entity:
Depends on another entity for existence.
Is also called as a weak entity.
Independent entity:
Does not depend on any other entity for existence.
Is also called as a regular entity.
Independent
Entity
Dependent
Entity
Copyright © 2009, Oracle. All rights reserved.
I - 21
 Relationship among entities:
 A relationship is depicted as a diamond with the name of the
relationship type.
Relationship
For example:
Copyright © 2009, Oracle. All rights reserved.
I - 22
 The following diagram represents the association of an entity with itself.
STUDENT
SEMINAR
An entity associating with
itself can be a student giving
a seminar presentation to
other students.
Copyright © 2009, Oracle. All rights reserved.
I - 23
 The following statement has been extracted from a case presented by a
manufacturer regarding the maintenance of their data: “A supplier ships
certain parts”. Identify the entities mentioned in this statement, and their
relationship. Draw a diagram depicting the relationship.
Solution:
Entities: SUPPLIER, PARTS
Relationship: SHIP or SUPPLIES
Copyright © 2009, Oracle. All rights reserved.
I - 24
 There are three types of relationships:
One-to-one
One-to-many (or Many-to-one)
Many-to-many
Copyright © 2009, Oracle. All rights reserved.
I - 25
 The following diagram represents the one-to-one relationship between
DEPARTMENT and DEPARTMENT HEAD.
For a particular DEPARTMENT there can be only one DEPARTMENT HEAD.
Copyright © 2009, Oracle. All rights reserved.
I - 26
 The following diagram represents the many-to-one relationship between
STUDENT and MAJOR.
A STUDENT can MAJOR in only one course, but many STUDENTs can register for a
given MAJOR course.
Copyright © 2009, Oracle. All rights reserved.
I - 27
 The following diagram represents the many-to-many relationship between
STUDENT and COURSE.
A STUDENT can take many COURSEs and many STUDENTs can register for a given COURSE.
Copyright © 2009, Oracle. All rights reserved.
I - 28
 What do the following ER diagrams represent?
Solution:
Many students can work on many projects.
Many employees belong to only one department.
Copyright © 2009, Oracle. All rights reserved.
I - 29
 Consider the following statement of a manufacturing company:
“A supplier supplies certain parts. A particular part is not necessarily supplied
by only one supplier. No supplier supplies only a single part.” What type of
relationship is this? Draw a diagram to depict the relationship.
Solution:
Many-to-many relationship
Copyright © 2009, Oracle. All rights reserved.
I - 30
 An attribute:
Is a property of a given entity.
Is depicted as ellipses, labeled with the name of the property.
The following diagram shows the various attributes of the entity, STUDENT.
Copyright © 2009, Oracle. All rights reserved.
I - 31
 A manufacturer needs to maintain the following details about the supplier:
Name
Address
Credit status
Assigned code number
Draw a diagram to depict this information.
Solution:
Copyright © 2009, Oracle. All rights reserved.
I - 32
 A subtype:
Is a subset of another entity.
Is always dependent on the supertype for its existence.
 The attributes of a supertype apply to all of its subtypes.
Copyright © 2009, Oracle. All rights reserved.
I - 33
 The following diagram shows the relationship between supertype
(PATIENT) and subtypes (INPATIENT and OUTPATIENT).
PATIENT
ID
Name
Addr
OUTPATIENT
INPATIENT
VstDate
RoomNo BedNo
Copyright © 2009, Oracle. All rights reserved.
I - 34
Map an ER diagram to a table
 The following components play an important part while mapping an
ER diagram to table:
o Regular entities
o Attributes
o Relationships
o Weak entities
o Subtypes and supertypes
Copyright © 2009, Oracle. All rights reserved.
I - 35
 Regular entities:
 They can exist alone, independent of any other entity.
 They are the “building blocks” of the database.
 Each regular entity maps to a table.
 For example, STUDENT and BOOKS are two separate entities in the
following ER diagram.
STUDENT BOOKS
ISSUES
Copyright © 2009, Oracle. All rights reserved.
I - 36
 Attributes:
 Each property or attribute shown in the ER diagram maps to an attribute
in the appropriate table.
 In the following ER diagram, STUDENT and BOOKS individually has
different attributes.
Entity becomes the table and the
attributes of the entity become
columns of the table.
Copyright © 2009, Oracle. All rights reserved.
I - 37
 Relationships:
There are the following types of relationships:
 One-to-One
 One-to-Many
 Many-to-Many
Copyright © 2009, Oracle. All rights reserved.
I - 38
 One-to-one relationship:
 One instance of an entity can relate to only one instance of the related entity.
If frequent queries require data from
the two tables, then it is better to
merge the two tables to improve
query performance.
For example:
Copyright © 2009, Oracle. All rights reserved.
I - 39
 One-to-many relationship:
 One instance of an entity can relate to more than one instance of the related entity.
Mapped to the
DEPARTMENT
table
Mapped to the
EMPLOYEE
table
For example:
Copyright © 2009, Oracle. All rights reserved.
I - 40
 Many-to-many relationship:
 Many instances of an entity can relate to more than one instance of the related
entity.
The primary keys, ROLL_NO and CODE of
the STUDENT and BOOKS table will act as
the foreign keys in the ISSUE table.
Mapped to the
STUDENT
table
Mapped to
the BOOKS
table
Mapped to
the ISSUES
table
For example:
Copyright © 2009, Oracle. All rights reserved.
I - 41
 For example, a user wants to know which book was issued to a particular
student and on which date. You can use the foreign keys in the ISSUE table to
make a join between all the three tables.
ROLL_NO NAME CODE DESC ISSUE_DATE RETURN_DATE
 What is the primary key of the ISSUE table? There are two possibilities. One
possibility is to take a combination of the two foreign keys (ROLL_NO and CODE)
The resulting key is known as Composite Key.
 Another possibility is to create a new attribute for the primary key, for example
ISSUENUM.
ISSUENUM ROLL_NO CODE ISSUE_DATE RETURN_DATE
Copyright © 2009, Oracle. All rights reserved.
I - 42
 Weak entity:
 It is an entity whose existence depends on some other entity.
The EMPLOYEEADDRESS
entity can be mapped to a
separate table.
ADDRESSID EMPNO CITY
For example:
Copyright © 2009, Oracle. All rights reserved.
I - 43
 Subtypes and Supertypes:
 A subtype is a subset of another entity.
 A subtype is always dependent on supertype for its existence.
 The primary key of the supertype creates a link between the
supertype and subtypes.
Copyright © 2009, Oracle. All rights reserved.
I - 44
For example:
Each subtype and
supertype maps to a
separate table.
Supertype
Subtypes
Copyright © 2009, Oracle. All rights reserved.
I - 45
 An RDBMS identifies and locates rows by value.
 Relational systems require keys that can uniquely identify the rows of a table.
 The various types of keys used in an RDBMS are:
o Primary
o Foreign
o Candidate
o Alternate
o Composite
 Keys
Copyright © 2009, Oracle. All rights reserved.
I - 46
 Any attribute (or set of attributes) that uniquely identifies a row in a
table is a candidate for the primary key. Such an attribute is called a
candidate key.
 One of the candidate keys is chosen to be the primary key, based on
the familiarity and greater usage.
 Any attribute that is a candidate for the primary key but is not the
primary key is called the alternate key.
 When the key that uniquely identifies the rows of the table is made up
of more than one attribute, it is called a composite key.
 Keys (Contd)
Copyright © 2009, Oracle. All rights reserved.
I - 47
 Consider the STUDENT table, as shown in the following diagram.
STUDENT# and REGN# are
both individually unique in every
row.
If STUDENT# is chosen as the
primary key, then REGN# is the
alternate key.
Candidate keys
Primary key Alternate key
Copyright © 2009, Oracle. All rights reserved.
I - 48
 Keys can be simple or composite. A Simple key is composed of a
singe attribute.
 A composite key, on the other hand, comprises two or more attributes.
ACCNUM TRANSDATE TRANSTIME AMOUNT DESCRIPTION
A1101 01/02/2001 12:30 P.M 1000.00 Deposit
A1102 01/02/2001 12:30 P.M 2000.00 Deposit
A1101 02/02/2001 10:30 P.M 3000.00 Deposit
 In the preceding table, assume that only one transaction can take
place for a given account number at a time.
 We can select ACCNUM, TRANSDATE, and TRANSTIME as the
composite key.
Copyright © 2009, Oracle. All rights reserved.
I - 49
 Consider the table, WORKING HOURS of an employee, as shown in the
following diagram.
EMPLID PROJECTID HOURS
E309 P675 18
E453 P908 5
E334 P876 20
Composite key
Each row can be uniquely identified by a
composite key composed of EMPLID and
PROJECTID.

More Related Content

PPTX
Module 3 Database systems for DIPLOMA.pptx
PPTX
inbound4905258819833329216.pptx
PPTX
Database management systems 3 - Data Modelling
PPTX
er-models.pptx
PPT
Week 4 The Relational Data Model & The Entity Relationship Data Model
PPTX
Unit-1-DBMS-SUN-4 everything you need to know.pptx
PPTX
Database Management System
PPT
introduction-to-dbms-unit-1.ppt
Module 3 Database systems for DIPLOMA.pptx
inbound4905258819833329216.pptx
Database management systems 3 - Data Modelling
er-models.pptx
Week 4 The Relational Data Model & The Entity Relationship Data Model
Unit-1-DBMS-SUN-4 everything you need to know.pptx
Database Management System
introduction-to-dbms-unit-1.ppt

Similar to RDBMS.ppt What is RDBMS RDBMS stands for Relational Database Management System. (20)

PDF
Data Models & Introduction to UML
PDF
Dbms 2: Data Model
PPTX
A database is a means of storing information in such a way that information c...
PPSX
DBMS_(MySql).ppsx database sql file my sql codes
PDF
Db lec 02_new
PPTX
Introduction of Database Design and Development
PDF
Unit1 rdbms study_materials-converted (1) (1)
PDF
Unit1 rdbms study_materials
PDF
DBMS Unit 1 nice content please download it
PPTX
Data Models and Relational Database Design.pptx
PPTX
DATA MODEL PRESENTATION UNIT I-BCA I.pptx
PDF
PPTX
DBMS-Unit-1.pptx
PPSX
DISE - Database Concepts
PDF
database management system - overview of entire dbms
PPTX
Database Management System
PPTX
DBMS-2.pptx
DOC
introduction of database in DBMS
PPTX
Day 1 SQL.pptx
PPTX
SQL.pptx
Data Models & Introduction to UML
Dbms 2: Data Model
A database is a means of storing information in such a way that information c...
DBMS_(MySql).ppsx database sql file my sql codes
Db lec 02_new
Introduction of Database Design and Development
Unit1 rdbms study_materials-converted (1) (1)
Unit1 rdbms study_materials
DBMS Unit 1 nice content please download it
Data Models and Relational Database Design.pptx
DATA MODEL PRESENTATION UNIT I-BCA I.pptx
DBMS-Unit-1.pptx
DISE - Database Concepts
database management system - overview of entire dbms
Database Management System
DBMS-2.pptx
introduction of database in DBMS
Day 1 SQL.pptx
SQL.pptx
Ad

Recently uploaded (20)

PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
master seminar digital applications in india
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Sports Quiz easy sports quiz sports quiz
PDF
Computing-Curriculum for Schools in Ghana
PDF
RMMM.pdf make it easy to upload and study
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
Pharma ospi slides which help in ospi learning
PDF
Pre independence Education in Inndia.pdf
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
Cell Types and Its function , kingdom of life
PDF
Classroom Observation Tools for Teachers
PDF
Insiders guide to clinical Medicine.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Microbial diseases, their pathogenesis and prophylaxis
O5-L3 Freight Transport Ops (International) V1.pdf
102 student loan defaulters named and shamed – Is someone you know on the list?
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
master seminar digital applications in india
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Sports Quiz easy sports quiz sports quiz
Computing-Curriculum for Schools in Ghana
RMMM.pdf make it easy to upload and study
GDM (1) (1).pptx small presentation for students
Pharma ospi slides which help in ospi learning
Pre independence Education in Inndia.pdf
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Cell Types and Its function , kingdom of life
Classroom Observation Tools for Teachers
Insiders guide to clinical Medicine.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Abdominal Access Techniques with Prof. Dr. R K Mishra
Microbial diseases, their pathogenesis and prophylaxis
Ad

RDBMS.ppt What is RDBMS RDBMS stands for Relational Database Management System.

  • 1. Copyright © 2009, Oracle. All rights reserved. Introduction
  • 2. Copyright © 2009, Oracle. All rights reserved. I - 2 Requirements of an Application:
  • 3. Copyright © 2009, Oracle. All rights reserved. I - 3  Information is a critical factor for any business to be successful. Information is extracted from data stored in databases.  Database is an integral part of an organization. Aspiring database developers should be able to efficiently design and implement databases.  Knowledge of these will enable the developers to build robust database solutions.  This module will help students to understand the concepts related to relational databases.
  • 4. Copyright © 2009, Oracle. All rights reserved. I - 4 What is a Database?
  • 5. Copyright © 2009, Oracle. All rights reserved. I - 5  A database is a collection of logically related data.  Data means known facts, which are meaningful and can be recorded. For example: Hard Disk Address Book
  • 6. Copyright © 2009, Oracle. All rights reserved. I - 6  Database Management is the task of maintaining databases so that the information is easily available.  Database Management Systems (DBMS) is the software required to perform the task of maintaining databases.  Management of data involves:  Defining structures for data storage.  Providing methods for data manipulation, such as adding, editing, and deleting data.  Providing data security against unauthorized access.  Database management systems are now available on a wide range of computers, from desktops to mainframes. The size and power of the computer determines the system facilities, such as security and storage.
  • 7. Copyright © 2009, Oracle. All rights reserved. I - 7 The main objectives of any DBMS are to:  Provide an efficient and easy way to store, update, and retrieve data from a database.  Manage information about users who interact with the DBMS, and the tasks that these users can perform on the data. Today, relational databases are the most popular form of storing data. Besides storing data and extracting information, a database has to be managed effectively. The software that is used to manage and retrieve information in a relational database is called a Relational Database Management System (RDBMS). A Relational Database Management System (RDBMS) is an advanced version of DBMS that also defines the relationship between various data values.
  • 8. Copyright © 2009, Oracle. All rights reserved. I - 8  Some typical applications of an RDBMS are:  Airline and railway reservations  Banking applications  Manufacturing industry  Order processing  Hospital management systems  Library management systems  Hotel industry
  • 9. Copyright © 2009, Oracle. All rights reserved. I - 9 Several RDBMS products are available today. Some popular products are:  Oracle  Microsoft SQL Server  Sybase  Ingres  DB2
  • 10. Copyright © 2009, Oracle. All rights reserved. I - 10 Now, let us understand the working of DBMS.
  • 11. Copyright © 2009, Oracle. All rights reserved. I - 11 Database DBMS Request for data Retrieved data returned as a result User system to extract information from the database
  • 12. Copyright © 2009, Oracle. All rights reserved. I - 12  Relational data structure:  Each table in a database has a unique table name.  The row (or record) in the table is called a tuple.  The column (or field) is called an attribute.  Every column in a table must have a unique name.  The number of tuples is called the cardinality of the table.  The number of attributes is called the degree of the table.  Rows are unordered in a relation.  A column or combination of columns that uniquely identifies each row in the table is called the primary key of the table.  A table where every row is different from all other rows is called a relation.  A domain is a collection of values from which one or more attributes (columns) draw their actual values.
  • 13. Copyright © 2009, Oracle. All rights reserved. I - 13 The following diagram describes the data structure of an RDBMS. T_CODE NAME AGE SEMESTER I1001 Nancy Mathews 27 I I1002 Catherine 38 II I1003 Mac Thams 50 IV I1004 Joe Nelson 35 III Tuple
  • 14. Copyright © 2009, Oracle. All rights reserved. I - 14 T_CODE NAME AGE SEMESTER I1001 Nancy Mathews 27 I I1002 Catherine 38 II I1003 Mac Thams 50 IV I1004 Joe Nelson 35 III Attributes The following diagram describes the data structure of an RDBMS.
  • 15. Copyright © 2009, Oracle. All rights reserved. I - 15 T_CODE NAME AGE SEMESTER I1001 Nancy Mathews 27 I I1002 Catherine 38 II I1003 Mac Thams 50 IV I1004 Joe Nelson 35 III Primary Key Relation The following diagram describes the data structure of an RDBMS.
  • 16. Copyright © 2009, Oracle. All rights reserved. I - 16 T_CODE NAME AGE SEMESTER I1001 Nancy Mathews 27 I I1002 Catherine 38 II I1003 Mac Thams 50 IV I1004 Joe Nelson 35 III DOMAIN T_CODE DOMAIN NAME DOMAIN AGE DOMAIN SEMESTER The following diagram describes the data structure of an RDBMS.
  • 17. Copyright © 2009, Oracle. All rights reserved. I - 17  Representing missing information:  In RDBMS, missing or unknown information is represented as a NULL value in a table.  NULL is not the same as space or zero.  Representing relationships in an RDBMS:  A column in one table whose value matches the primary key in some other table is called a foreign key.  A primary key and a foreign key create a parent-child relationship between the tables that connect them.
  • 18. Copyright © 2009, Oracle. All rights reserved. I - 18  The ER (Entity-Relationship) model: Views the real world as a collection of objects or entities and the relationship among them. It also has a corresponding diagramming technique. STUDENT COURSE LEARN Sno Sname CrsID Crsname Entities Relationship Attributes Attributes
  • 19. Copyright © 2009, Oracle. All rights reserved. I - 19  An entity:  Is any object, place, person, or activity about which the data is recorded.  Can be categorized as entity type and entity instance.  In the ER model diagramming technique, entities are named and represented inside a box. For example: TEACHER
  • 20. Copyright © 2009, Oracle. All rights reserved. I - 20  Entity can be of the following types: Dependent entity: Depends on another entity for existence. Is also called as a weak entity. Independent entity: Does not depend on any other entity for existence. Is also called as a regular entity. Independent Entity Dependent Entity
  • 21. Copyright © 2009, Oracle. All rights reserved. I - 21  Relationship among entities:  A relationship is depicted as a diamond with the name of the relationship type. Relationship For example:
  • 22. Copyright © 2009, Oracle. All rights reserved. I - 22  The following diagram represents the association of an entity with itself. STUDENT SEMINAR An entity associating with itself can be a student giving a seminar presentation to other students.
  • 23. Copyright © 2009, Oracle. All rights reserved. I - 23  The following statement has been extracted from a case presented by a manufacturer regarding the maintenance of their data: “A supplier ships certain parts”. Identify the entities mentioned in this statement, and their relationship. Draw a diagram depicting the relationship. Solution: Entities: SUPPLIER, PARTS Relationship: SHIP or SUPPLIES
  • 24. Copyright © 2009, Oracle. All rights reserved. I - 24  There are three types of relationships: One-to-one One-to-many (or Many-to-one) Many-to-many
  • 25. Copyright © 2009, Oracle. All rights reserved. I - 25  The following diagram represents the one-to-one relationship between DEPARTMENT and DEPARTMENT HEAD. For a particular DEPARTMENT there can be only one DEPARTMENT HEAD.
  • 26. Copyright © 2009, Oracle. All rights reserved. I - 26  The following diagram represents the many-to-one relationship between STUDENT and MAJOR. A STUDENT can MAJOR in only one course, but many STUDENTs can register for a given MAJOR course.
  • 27. Copyright © 2009, Oracle. All rights reserved. I - 27  The following diagram represents the many-to-many relationship between STUDENT and COURSE. A STUDENT can take many COURSEs and many STUDENTs can register for a given COURSE.
  • 28. Copyright © 2009, Oracle. All rights reserved. I - 28  What do the following ER diagrams represent? Solution: Many students can work on many projects. Many employees belong to only one department.
  • 29. Copyright © 2009, Oracle. All rights reserved. I - 29  Consider the following statement of a manufacturing company: “A supplier supplies certain parts. A particular part is not necessarily supplied by only one supplier. No supplier supplies only a single part.” What type of relationship is this? Draw a diagram to depict the relationship. Solution: Many-to-many relationship
  • 30. Copyright © 2009, Oracle. All rights reserved. I - 30  An attribute: Is a property of a given entity. Is depicted as ellipses, labeled with the name of the property. The following diagram shows the various attributes of the entity, STUDENT.
  • 31. Copyright © 2009, Oracle. All rights reserved. I - 31  A manufacturer needs to maintain the following details about the supplier: Name Address Credit status Assigned code number Draw a diagram to depict this information. Solution:
  • 32. Copyright © 2009, Oracle. All rights reserved. I - 32  A subtype: Is a subset of another entity. Is always dependent on the supertype for its existence.  The attributes of a supertype apply to all of its subtypes.
  • 33. Copyright © 2009, Oracle. All rights reserved. I - 33  The following diagram shows the relationship between supertype (PATIENT) and subtypes (INPATIENT and OUTPATIENT). PATIENT ID Name Addr OUTPATIENT INPATIENT VstDate RoomNo BedNo
  • 34. Copyright © 2009, Oracle. All rights reserved. I - 34 Map an ER diagram to a table  The following components play an important part while mapping an ER diagram to table: o Regular entities o Attributes o Relationships o Weak entities o Subtypes and supertypes
  • 35. Copyright © 2009, Oracle. All rights reserved. I - 35  Regular entities:  They can exist alone, independent of any other entity.  They are the “building blocks” of the database.  Each regular entity maps to a table.  For example, STUDENT and BOOKS are two separate entities in the following ER diagram. STUDENT BOOKS ISSUES
  • 36. Copyright © 2009, Oracle. All rights reserved. I - 36  Attributes:  Each property or attribute shown in the ER diagram maps to an attribute in the appropriate table.  In the following ER diagram, STUDENT and BOOKS individually has different attributes. Entity becomes the table and the attributes of the entity become columns of the table.
  • 37. Copyright © 2009, Oracle. All rights reserved. I - 37  Relationships: There are the following types of relationships:  One-to-One  One-to-Many  Many-to-Many
  • 38. Copyright © 2009, Oracle. All rights reserved. I - 38  One-to-one relationship:  One instance of an entity can relate to only one instance of the related entity. If frequent queries require data from the two tables, then it is better to merge the two tables to improve query performance. For example:
  • 39. Copyright © 2009, Oracle. All rights reserved. I - 39  One-to-many relationship:  One instance of an entity can relate to more than one instance of the related entity. Mapped to the DEPARTMENT table Mapped to the EMPLOYEE table For example:
  • 40. Copyright © 2009, Oracle. All rights reserved. I - 40  Many-to-many relationship:  Many instances of an entity can relate to more than one instance of the related entity. The primary keys, ROLL_NO and CODE of the STUDENT and BOOKS table will act as the foreign keys in the ISSUE table. Mapped to the STUDENT table Mapped to the BOOKS table Mapped to the ISSUES table For example:
  • 41. Copyright © 2009, Oracle. All rights reserved. I - 41  For example, a user wants to know which book was issued to a particular student and on which date. You can use the foreign keys in the ISSUE table to make a join between all the three tables. ROLL_NO NAME CODE DESC ISSUE_DATE RETURN_DATE  What is the primary key of the ISSUE table? There are two possibilities. One possibility is to take a combination of the two foreign keys (ROLL_NO and CODE) The resulting key is known as Composite Key.  Another possibility is to create a new attribute for the primary key, for example ISSUENUM. ISSUENUM ROLL_NO CODE ISSUE_DATE RETURN_DATE
  • 42. Copyright © 2009, Oracle. All rights reserved. I - 42  Weak entity:  It is an entity whose existence depends on some other entity. The EMPLOYEEADDRESS entity can be mapped to a separate table. ADDRESSID EMPNO CITY For example:
  • 43. Copyright © 2009, Oracle. All rights reserved. I - 43  Subtypes and Supertypes:  A subtype is a subset of another entity.  A subtype is always dependent on supertype for its existence.  The primary key of the supertype creates a link between the supertype and subtypes.
  • 44. Copyright © 2009, Oracle. All rights reserved. I - 44 For example: Each subtype and supertype maps to a separate table. Supertype Subtypes
  • 45. Copyright © 2009, Oracle. All rights reserved. I - 45  An RDBMS identifies and locates rows by value.  Relational systems require keys that can uniquely identify the rows of a table.  The various types of keys used in an RDBMS are: o Primary o Foreign o Candidate o Alternate o Composite  Keys
  • 46. Copyright © 2009, Oracle. All rights reserved. I - 46  Any attribute (or set of attributes) that uniquely identifies a row in a table is a candidate for the primary key. Such an attribute is called a candidate key.  One of the candidate keys is chosen to be the primary key, based on the familiarity and greater usage.  Any attribute that is a candidate for the primary key but is not the primary key is called the alternate key.  When the key that uniquely identifies the rows of the table is made up of more than one attribute, it is called a composite key.  Keys (Contd)
  • 47. Copyright © 2009, Oracle. All rights reserved. I - 47  Consider the STUDENT table, as shown in the following diagram. STUDENT# and REGN# are both individually unique in every row. If STUDENT# is chosen as the primary key, then REGN# is the alternate key. Candidate keys Primary key Alternate key
  • 48. Copyright © 2009, Oracle. All rights reserved. I - 48  Keys can be simple or composite. A Simple key is composed of a singe attribute.  A composite key, on the other hand, comprises two or more attributes. ACCNUM TRANSDATE TRANSTIME AMOUNT DESCRIPTION A1101 01/02/2001 12:30 P.M 1000.00 Deposit A1102 01/02/2001 12:30 P.M 2000.00 Deposit A1101 02/02/2001 10:30 P.M 3000.00 Deposit  In the preceding table, assume that only one transaction can take place for a given account number at a time.  We can select ACCNUM, TRANSDATE, and TRANSTIME as the composite key.
  • 49. Copyright © 2009, Oracle. All rights reserved. I - 49  Consider the table, WORKING HOURS of an employee, as shown in the following diagram. EMPLID PROJECTID HOURS E309 P675 18 E453 P908 5 E334 P876 20 Composite key Each row can be uniquely identified by a composite key composed of EMPLID and PROJECTID.