Unit - I - Introduction To DBMS
Unit - I - Introduction To DBMS
Course Details
Course Outcomes and Course Objectives
Course Details
Course Outcomes:
❖ To implement the underlying concepts of a database system.
❖ Formulate, using SQL/DML/DDL commands, solutions to a wide range of query and
update problems.
Unit I: Introduction to DBMS
Introduction to Database Management Systems, Purpose of
Database Systems, Database-System Applications, Data
Abstraction and Database System Structure.
Relational Model: Structure of relational databases, Domains,
Relations, Relational algebra – fundamental operators and syntax,
relational algebra queries, tuple relational calculus.
Entity-Relationship model: Basic Concepts, Entity Set,
Relationship Sets and Weak Entity Sets, Mapping Cardinalities,
Keys, E-R diagrams, Design Issues, Extended E-R Features,
Converting E-R & EER diagram into tables.
Unit I: Introduction to DBMS
Database Applications
Banking: Transactions
Airlines: reservations, schedules
Universities: registration, grades
Sales: customers, products, purchases
Online retailers: order tracking, customized recommendations
Manufacturing: production, inventory, orders, supply chain
Human resource: employee records, salaries, tax deductions
……
Introduction to Database Management Systems
➢ Security problems
❖ Hard to provide user access to some, but not all, data
Database-System Applications
• Account Schema
Account Instance
Account No Account Type Interest Rate Min.bal Balance
917322 Savings 4.0% 5000 7812
827183 Current 0.0% 0 291820
372912 Term Deposit 6.75% 10000 100000
Schemas and Instances
Data Models
Data Models
The structure of the database is called data model.
A collection of tools for describing
Data
Data relationships
Data semantics
Data constraints
Relational Model (we focus in this)
Entity relationships data models (mainly for database design)
Object based data models (object oriented and object related)
Semi-structured data model (XML)
Database System Structure: Database Users
Database System Structure: Architecture
Quiz 1: Scratch Your Head?
https://forms.office.com/r/gj3r9N6Tbk
Relational Model
Rows
Relational Model: Structure of relational databases
Relational Model: Structure of relational databases
tuples
(or rows)
Relational Model: Structure of relational databases
➢ The set of allowed values for each attribute is called the domain of
the attribute
➢ Attribute values are (normally) required to be atomic; that is,
indivisible
➢ The special value null is a member of every domain. Indicated that
the value is “unknown”
➢ The null value causes complications in the definition of many
operations
Relational Model: Relational Algebra
➢ Select Operation
➢ The select operation selects tuples that satisfy a given predicate.
➢ Notation: p (r)
➢ p is called the selection predicate
➢ Example: select those tuples of the instructor relation where the
instructor is in the “Physics” department.
➢ Query
dept_name=“Physics” (instructor)
➢ Result
Select Operation – selection of rows (tuples)
▪ Relation r
▪A≠B (r)
▪C > 0 (r)
▪ D <1 (r)
Relational Model: Relational Algebra & Queries
➢ We allow comparisons using
=, , >, , <,
in the selection predicate.
➢ We can combine several predicates into a larger predicate by using the
connectives:
(and), (or), (not)
➢ Example: Find the instructors in Physics with a salary greater $90,000, we write:
dept_name=building (department)
Relational Model: Relational Algebra & Queries
➢ Project Operation
➢ A unary operation that returns its argument relation, with certain
attributes left out.
Notation:
▪ Relation r:
▪ A,C (r)
Relational Model: Relational Algebra & Queries
➢ Project Operation
➢ Example: eliminate the dept_name attribute of instructor
▪ Relations r, s:
▪ r s:
Set difference of two relations
▪ Relations r, s:
▪ r – s:
Set intersection of two relations
▪ Relation r, s:
▪ rs
Note: r s = r – (r – s)
Relational Model: Relational Algebra & Queries
➢ Cartesian-Product Operation
➢ The Cartesian-product operation (denoted by X) allows us to combine
information from any two relations.
➢ Example: the Cartesian product of the relations instructor and teaches is
written as:
instructor X teaches
➢ We construct a tuple of the result out of each possible pair of tuples: one from
the instructor relation and one from the teaches relation (see next slide)
➢ Since the instructor ID appears in both relations we distinguish between these
attribute by attaching to the attribute the name of the relation from which
the attribute originally came.
instructor.ID
teaches.ID
Joining two relations -- Cartesian-product
▪ Relations r, s:
▪ r x s:
Cartesian-product – naming issue
▪ Relations r, s: B
▪ r x s: r.B s.B
Renaming a Table
▪ Allows us to refer to a relation, (say E) by more than one name.
x (E)
▪ Relations r
➢ Join Operation
➢ The Cartesian-Product
instructor X teaches
associates every tuple of instructor with every tuple of teaches.
➢ Most of the resulting rows have information about instructors who did NOT
teach a particular course.
➢ To get only those tuples of “instructor X teaches “ that pertain to instructors
and the courses that they taught, we write:
▪ Natural Join
n r s
Output pairs of rows from the two input relations that have the same value
on all attributes that have the same name.
∪
(Union) Π name (instructor) ∪ Π name (student)
Output the set difference of tuples from the two input relations.
⋈
(Natural Join) instructor ⋈ department
Output pairs of rows from the two input relations that have the same value
on all attributes that have the same name.
Notes about Relational Languages
{t | t student(t[Roll_No]=s[Roll_No] }
Roll_No
Roll_No
101
102
2. Select Roll_No for each student having 102
104
marks<70 from student relation 104
103
{t | t student (t [Roll_No]=s [Roll_No] s[Marks]<70) }
Relational Model: Tuple Relational Calculus
• Find the ID, name, dept_name, salary for all instructors whose
salary is greater than 80000
{t |t instructor t[salary]>80000}
https://forms.office.com/r/5wzVe3A7JV
Entity-Relationship model: Basic Concepts
➢ Database Design
➢ Design Phases
➢ Initial phase of database design – is to characterize the needs of
database users. Outcome- specifications of user requirements.
➢ To choose data model and apply concepts of data model
translates these requirements into a conceptual schema.(E-R
model)
➢ Conceptual schema- Specifies entities, attributes,
relationship among those entities and constraints.
➢ Result- Creation of E-R diagram
➢ Specification of functional requirement
Entity-Relationship model: Basic Concepts
➢ Database Design
➢ Design Phases
➢ Initial phase of database design
➢ To choose data model and apply concepts of data model translates these
requirements into a conceptual schema.(E-R model)
➢ Specification of functional requirement
➢ Implementation of database
➢ Logical Design Phase
➢ Physical Design Phase
➢ In designing database schema, it is necessary to avoid two major problems
: Redundancy and Incompleteness
Entity-Relationship model: Basic Concepts
➢ Attribute types:
➢ Simple and composite attributes.
➢ Single-valued and multivalued attributes
➢ Example: multivalued attribute: phone_numbers
➢ Derived attributes
➢ Can be computed from other attributes
➢ Example: age, given date_of_birth
➢ Domain – the set of permitted values for each attribute
Entity-Relationship model: Weak Entity Sets
➢ The relationship associating the weak entity set with the identifying entity
set is called the identifying relationship.
➢ Note that the relational schema we eventually create from the entity set
section does have the attribute course_id, for reasons that will become clear
later, even though we have dropped the attribute course_id from the entity
set section.
➢ Express the number of entities to which another entity can be associated via a
relationship set.
➢ Most useful in describing binary relationship sets.
➢ For a binary relationship set the mapping cardinality must be one of the following types:
❖ One to one
❖ One to many
❖ Many to one
❖ Many to many
Entity-Relationship model: Primary key for Entity Sets
➢ Specialization
➢ Top-down design process;
❖ we designate sub-groupings within an entity set that are distinctive from other entities in the set.
➢ These sub-groupings become lower-level entity sets that have attributes or participate
in relationships that do not apply to the higher-level entity set.
➢ Depicted by a triangle component labeled ISA (e.g., instructor “is a” person).
➢ Attribute inheritance – a lower-level entity set inherits all the attributes and
relationship participation of the higher-level entity set to which it is linked.
Entity-Relationship model: Extended E-R Features
➢ Generalization
➢ A bottom-up design process –
❖ combine a number of entity sets that share the same features into a higher-level entity set.
➢ Specialization and generalization are simple inversions of each other;
they are represented in an E-R diagram in the same way.
➢ The terms specialization and generalization are used interchangeably.
Entity-Relationship model: Converting ER to Tables
https://forms.office.com/r/ytRZ9xyJjX