Docsity

Dbms tutorial, Study notes of Database Management Systems (DBMS)

Partial preview of the text

Download Dbms tutorial and more Study notes Database Management Systems (DBMS) in PDF only on Docsity!

i

About the Tutorial

Database Management System or DBMS in short refers to the technology of storing and retrieving users’ data with utmost efficiency along with appropriate security measures. DBMS allows its users to create their own databases as per their requirement. These databases are highly configurable and offer a bunch of options. This tutorial explains the basics of DBMS such as its architecture, data models, data schemas, data independence, E-R model, relation model, relational database design, and storage and file structure. In addition, it covers a few advanced topics such as indexing and hashing, transaction and concurrency, and backup and recovery.

Audience

This tutorial will especially help computer science graduates in understanding the basic-to-advanced concepts related to Database Management Systems.

Prerequisites

Before you start proceeding with this tutorial, it is recommended that you have a good understanding of basic computer concepts such as primary memory, secondary memory, and data structures and algorithms.

Copyright & Disclaimer

 Copyright 201 5 by Tutorials Point (I) Pvt. Ltd. All the content and graphics published in this e-book are the property of Tutorials Point (I) Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republish any contents or a part of contents of this e-book in any manner without written consent of the publisher. We strive to update the contents of our website and tutorials as timely and as precisely as possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt. Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our website or its contents including this tutorial. If you discover any errors on our website or in this tutorial, please notify us at [email protected]

iii

  • Relationship
    1. ER DIAGRAM REPRESENTATION
    • Entity
    • Attributes
    • Relationship
    1. GENERALIZATION & SPECIALIZATION
    • Generalization
    • Specialization
    • Inheritance
    1. CODD’S 12 RULES................................................................................................................
    • Rule 1: Information Rule
    • Rule 2: Guaranteed Access Rule
    • Rule 3: Systematic Treatment of NULL Values
    • Rule 4: Active Online Catalog
    • Rule 5: Comprehensive Data Sub-Language Rule
    • Rule 6: View Updating Rule
    • Rule 7: High-Level Insert, Update, and Delete Rule
    • Rule 8: Physical Data Independence........................................................................................................
    • Rule 9: Logical Data Independence
    • Rule 10: Integrity Independence
    • Rule 11: Distribution Independence
    • Rule 12: Non-Subversion Rule
    1. RELATIONAL DATA MODEL
    • Concepts
    • Constraints..............................................................................................................................................
    1. RELATIONAL ALGEBRA......................................................................................................... iv
    • Relational Algebra
    • Relational Calculus
    1. ER MODEL TO RELATIONAL MODEL
    • Mapping Entity
    • Mapping Relationship
    • Mapping Weak Entity Sets
    • Mapping Hierarchical Entities
    1. SQL OVERVIEW....................................................................................................................
    • Data Definition Language
    • Data Manipulation Language
    1. NORMALIZATION
    • Functional Dependency
    • Armstrong's Axioms
    • Trivial Functional Dependency
    • Normalization
    • First Normal Form
    • Second Normal Form
    • Third Normal Form..................................................................................................................................
    • Boyce-Codd Normal Form
    1. JOINS...................................................................................................................................
    • Theta (θ) Join
    • Equijoin
    • Natural Join ( ⋈ )
    • Outer Joins
    1. STORAGE SYSTEM v
    • Memory Hierarchy
    • Magnetic Disks
    • RAID
    1. FILE STRUCTURE..................................................................................................................
    • File Organization
    • File Operations........................................................................................................................................
    1. INDEXING
    • Dense Index
    • Sparse Index
    • Multilevel Index
    • B+ Tree
    1. HASHING
    • Hash Organization...................................................................................................................................
    • Static Hashing
    • Bucket Overflow
    • Dynamic Hashing
    • Organization
    • Operation
    1. TRANSACTION
    • ACID Properties.......................................................................................................................................
    • Serializability
    • Equivalence Schedules
    • States of Transactions
    1. CONCURRENCY CONTROL
    • Lock-based Protocols vi
    • Timestamp-based Protocols
    • Timestamp Ordering Protocol
    1. DEADLOCK
    • Deadlock Prevention
    • Deadlock Avoidance................................................................................................................................
    1. DATA BACKUP
    • Loss of Volatile Storage
    • Database Backup & Recovery from Catastrophic Failure
    • Remote Backup
    1. DATA RECOVERY
    • Crash Recovery
    • Failure Classification
    • Storage Structure
    • Recovery and Atomicity
    • Log-based Recovery
    • Recovery with Concurrent Transactions

DBMS

Database is a collection of related data and data is a collection of facts and figures that can be processed to produce information. Mostly data represents recordable facts. Data aids in producing information, which is based on facts. For example, if we have data about marks obtained by all students, we can then conclude about toppers and average marks. A database management system stores data in such a way that it becomes easier to retrieve, manipulate, and produce information.

Characteristics

Traditionally, data was organized in file formats. DBMS was a new concept then, and all the research was done to make it overcome the deficiencies in traditional style of data management. A modern DBMS has the following characteristics:  Real-world entity : A modern DBMS is more realistic and uses real-world entities to design its architecture. It uses the behavior and attributes too. For example, a school database may use students as an entity and their age as an attribute.  Relation-based tables : DBMS allows entities and relations among them to form tables. A user can understand the architecture of a database just by looking at the table names.  Isolation of data and application : A database system is entirely different than its data. A database is an active entity, whereas data is said to be passive, on which the database works and organizes. DBMS also stores metadata, which is data about data, to ease its own process.  Less redundancy : DBMS follows the rules of normalization, which splits a relation when any of its attributes is having redundancy in values. Normalization is a mathematically rich and scientific process that reduces data redundancy.  Consistency : Consistency is a state where every relation in a database remains consistent. There exist methods and techniques, which can detect attempt of leaving database in inconsistent state. A DBMS can provide greater consistency as compared to earlier forms of data storing applications like file-processing systems.  Query Language : DBMS is equipped with query language, which makes it more efficient to retrieve and manipulate data. A user can apply as many and as different filtering options as required to retrieve a set of

1. OVERVIEW

DBMS

Administrators : Administrators maintain the DBMS and are responsible for administrating the database. They are responsible to look after its usage and by whom it should be used. They create access profiles for users and apply limitations to maintain isolation and force security. Administrators also look after DBMS resources like system license, required tools, and other software and hardware related maintenance.  Designers : Designers are the group of people who actually work on the designing part of the database. They keep a close watch on what data should be kept and in what format. They identify and design the whole set of entities, relations, constraints, and views.  End Users : End users are those who actually reap the benefits of having a DBMS. End users can range from simple viewers who pay attention to the logs or market rates to sophisticated users such as business analysts.

DBMS

The design of a DBMS depends on its architecture. It can be centralized or decentralized or hierarchical. The architecture of a DBMS can be seen as either single tier or multi-tier. An n-tier architecture divides the whole system into related but independent n modules, which can be independently modified, altered, changed, or replaced. In 1-tier architecture, the DBMS is the only entity where the user directly sits on the DBMS and uses it. Any changes done here will directly be done on the DBMS itself. It does not provide handy tools for end-users. Database designers and programmers normally prefer to use single-tier architecture. If the architecture of DBMS is 2-tier, then it must have an application through which the DBMS can be accessed. Programmers use 2-tier architecture where they access the DBMS by means of an application. Here the application tier is entirely independent of the database in terms of operation, design, and programming.

3 - tier Architecture

A 3 - tier architecture separates its tiers from each other based on the complexity of the users and how they use the data present in the database. It is the most widely used architecture to design a DBMS. [ Image: 3-tier DBMS architecture ]  Database (Data) Tier : At this tier, the database resides along with its query processing languages. We also have the relations that define the data and their constraints at this level.

2. ARCHITECTURE

DBMS

Data models define how the logical structure of a database is modeled. Data Models are fundamental entities to introduce abstraction in a DBMS. Data models define how data is connected to each other and how they are processed and stored inside the system. The very first data model could be flat data-models, where all the data used are to be kept in the same plane. Earlier data models were not so scientific, hence they were prone to introduce lots of duplication and update anomalies.

Entity-Relationship Model

Entity-Relationship (ER) Model is based on the notion of real-world entities and relationships among them. While formulating real-world scenario into the database model, the ER Model creates entity set, relationship set, general attributes, and constraints. ER Model is best used for the conceptual design of a database. ER Model is based on:  Entities and their attributes_._  Relationships among entities. These concepts are explained below. [ Image: ER Model ]  Entity An entity in an ER Model is a real-world entity having properties called attributes. Every attribute is defined by its set of values called domain. For example, in a school database, a student is considered as an entity. Student has various attributes like name, age, class, etc.  Relationship

3. DATA MODELS

DBMS

The logical association among entities is called relationship. Relationships are mapped with entities in various ways. Mapping cardinalities define the number of association between two entities. Mapping cardinalities: o one to one o one to many o many to one o many to many

Relational Model

The most popular data model in DBMS is the Relational Model. It is more scientific a model than others. This model is based on first-order predicate logic and defines a table as an n-ary relation. [ Image: Table in relational Model ] The main highlights of this model are:  Data is stored in tables called relations.  Relations can be normalized.  In normalized relations, values saved are atomic values.  Each row in a relation contains a unique value.

DBMS

Database Schema

A database schema is the skeleton structure that represents the logical view of the entire database. It defines how the data is organized and how the relations among them are associated. It formulates all the constraints that are to be applied on the data. A database schema defines its entities and the relationship among them. It contains a descriptive detail of the database, which can be depicted by means of schema diagrams. It’s the database designers who design the schema to help programmers understand the database and make it useful. [ Image: Database Schemas ] A database schema can be divided broadly into two categories:

4. DATA SCHEMAS

DBMS

Physical Database Schema : This schema pertains to the actual storage of data and its form of storage like files, indices, etc. It defines how the data will be stored in a secondary storage.  Logical Database Schema : This schema defines all the logical constraints that need to be applied on the data stored. It defines tables, views, and integrity constraints.

Database Instance

It is important that we distinguish these two terms individually. Database schema is the skeleton of database. It is designed when the database doesn't exist at all. Once the database is operational, it is very difficult to make any changes to it. A database schema does not contain any data or information. A database instance is a state of operational database with data at any given time. It contains a snapshot of the database. Database instances tend to change with time. A DBMS ensures that its every instance (state) is in a valid state, by diligently following all the validations, constraints, and conditions that the database designers have imposed.

DBMS

Logical data independence is a kind of mechanism, which liberalizes itself from actual data stored on the disk. If we do some changes on table format, it should not change the data residing on the disk.

Physical Data Independence

All the schemas are logical, and the actual data is stored in bit format on the disk. Physical data independence is the power to change the physical data without impacting the schema or logical data. For example, in case we want to change or upgrade the storage system itself — suppose we want to replace hard-disks with SSD — it should not have any impact on the logical data or schemas.

DBMS

The ER model defines the conceptual view of a database. It works around real- world entities and the associations among them. At view level, the ER model is considered a good option for designing databases.

Entity

An entity can be a real-world object, either animate or inanimate, that can be easily identifiable. For example, in a school database, students, teachers, classes, and courses offered can be considered as entities. All these entities have some attributes or properties that give them their identity. An entity set is a collection of similar types of entities. An entity set may contain entities with attribute sharing similar values. For example, a Students set may contain all the students of a school; likewise a Teachers set may contain all the teachers of a school from all faculties. Entity sets need not be disjoint.

Attributes

Entities are represented by means of their properties called attributes. All attributes have values. For example, a student entity may have name, class, and age as attributes. There exists a domain or range of values that can be assigned to attributes. For example, a student's name cannot be a numeric value. It has to be alphabetic. A student's age cannot be negative, etc. Types of AttributesSimple attribute: Simple attributes are atomic values, which cannot be divided further. For example, a student's phone number is an atomic value of 10 digits.  Composite attribute: Composite attributes are made of more than one simple attribute. For example, a student's complete name may have first_name and last_name.  Derived attribute: Derived attributes are the attributes that do not exist in the physical database, but their values are derived from other attributes present in the database. For example, average_salary in a department should not be saved directly in the database, instead it can be derived. For another example, age can be derived from data_of_birth.

6. ER MODEL – BASIC CONCEPTS