SlideShare a Scribd company logo
1 of 49
Download to read offline
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

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

Database Concepts & SQL(1).pdf
Database Concepts & SQL(1).pdfDatabase Concepts & SQL(1).pdf
Database Concepts & SQL(1).pdf
rsujeet169
 
Dbms questions
Dbms questionsDbms questions
Dbms questions
Srikanth
 
3 data modeling using the entity-relationship (er) model
3 data modeling using the entity-relationship (er) model3 data modeling using the entity-relationship (er) model
3 data modeling using the entity-relationship (er) model
Kumar
 

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

Db lec 01
Db lec 01Db lec 01
Db lec 01
 
Bca examination 2017 dbms
Bca examination 2017 dbmsBca examination 2017 dbms
Bca examination 2017 dbms
 
Chapter03
Chapter03Chapter03
Chapter03
 
Schema Integration, View Integration and Database Integration, ER Model & Dia...
Schema Integration, View Integration and Database Integration, ER Model & Dia...Schema Integration, View Integration and Database Integration, ER Model & Dia...
Schema Integration, View Integration and Database Integration, ER Model & Dia...
 
Unit 1
Unit 1Unit 1
Unit 1
 
COMPUTERS Database
COMPUTERS Database COMPUTERS Database
COMPUTERS Database
 
NMEC RD_UNIT 1.ppt
NMEC RD_UNIT 1.pptNMEC RD_UNIT 1.ppt
NMEC RD_UNIT 1.ppt
 
Preparing for BIT – IT2301 Database Management Systems 2001d
Preparing for BIT – IT2301 Database Management Systems 2001dPreparing for BIT – IT2301 Database Management Systems 2001d
Preparing for BIT – IT2301 Database Management Systems 2001d
 
Data base management system(DBMS), sourav mathur
Data base management system(DBMS), sourav mathurData base management system(DBMS), sourav mathur
Data base management system(DBMS), sourav mathur
 
Database Concepts & SQL(1).pdf
Database Concepts & SQL(1).pdfDatabase Concepts & SQL(1).pdf
Database Concepts & SQL(1).pdf
 
Database 2018
Database 2018Database 2018
Database 2018
 
Dbms questions
Dbms questionsDbms questions
Dbms questions
 
chapter-13-database-concepts.pdf
chapter-13-database-concepts.pdfchapter-13-database-concepts.pdf
chapter-13-database-concepts.pdf
 
Data Modeling PPT
Data Modeling PPTData Modeling PPT
Data Modeling PPT
 
E-R diagram & SQL
E-R diagram & SQLE-R diagram & SQL
E-R diagram & SQL
 
3 data modeling using the entity-relationship (er) model
3 data modeling using the entity-relationship (er) model3 data modeling using the entity-relationship (er) model
3 data modeling using the entity-relationship (er) model
 
Bca examination 2015 dbms
Bca examination 2015 dbmsBca examination 2015 dbms
Bca examination 2015 dbms
 
How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17
 
Chapter03.pdf
Chapter03.pdfChapter03.pdf
Chapter03.pdf
 
Chapter03 (2).ppt
Chapter03 (2).pptChapter03 (2).ppt
Chapter03 (2).ppt
 

Recently uploaded

Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 

Recently uploaded (20)

TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17How to Manage Call for Tendor in Odoo 17
How to Manage Call for Tendor in Odoo 17
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 

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.