Week-1&2(CSPC-202)
Introduction to DBMS
         1.1
DEPARTMENT: COMPUTER SCIENCE AND ENGINEERING
 COURSE CODE: CSPC-202
 COURSE TITLE: DATABASE MANAGEMENT SYSTEM
 COURSE DESIGNATION: REQUIRED
 PRE-REQUISITES: File Management Using any Programming
  Language
                              1.2
                 COURSE OUTCOMES
   To understand the different issues involved in the design and implementation
    of a database system. To study the physical and logical database designs,
    database modeling, relational, hierarchical, and network models
   To understand and use data manipulation language to query, update, and
    manage a database
   To develop an understanding of essential DBMS concepts such as: database
    security, integrity, concurrency, distributed database, and intelligent database,
    Client/Server (Database Server), Data Warehousing.
   To design and build a simple database system and demonstrate competence
    with the fundamental tasks involved with modeling, designing, and
    implementing a DBMS.
                                          1.3
    TOPICS To Be COVERED
             1.4
    TOPICS To Be COVERED contd..
                 1.5
   TEXT BOOKS, AND/OR REFERENCE
            MATERIAL
 Korth, Silbertz, Sudarshan, “Database Concepts”, McGraw Hill
 Elmasri, Navathe, “Fundamentals Of Database Systems”, Addision
   Wesley
 Date C J, “An Introduction To Database System”, Addision Wesley
 Bipin C. Desai, “An introduction to Database Systems”, Galgotia
   Publication
 Rob and Coronel, “Database Systems 5thEdition”,Cengage Learning,
   New Delhi
                                   1.6
                           Outline
 The Need for Databases
 Data Models
 Relational Databases
 Database Design
 Storage Manager
 Query Processing
 Transaction Manager
                             1.7
  Database Management System (DBMS)
 DBMS contains information about a particular enterprise
       Collection of interrelated data
       Set of programs to access the data
       An environment that is both convenient and efficient to use
 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 resources: employee records, salaries, tax deductions
 Databases can be very large.
 Databases touch all aspects of our lives
                                      1.8
           University Database Example
 Application program examples
       Add new students, instructors, and courses
       Register students for courses, and generate class rosters
       Assign grades to students, compute grade point averages
        (GPA) and generate transcripts
 In the early days, database applications were built directly on
   top of file systems
                                     1.9
 Drawbacks of using file systems to store data
 Data redundancy and inconsistency
       Multiple file formats, duplication of information in different files
 Difficulty in accessing data
       Need to write a new program to carry out each new task
 Data isolation
       Multiple files and formats
 Integrity problems
       Integrity constraints (e.g., account balance > 0) become “buried”
        in program code rather than being stated explicitly
       Hard to add new constraints or change existing ones
                                        1.10
 Drawbacks of using file systems to store data (Cont.)
 Atomicity of updates
       Failures may leave database in an inconsistent state with partial
        updates carried out
       Example: Transfer of funds from one account to another should
        either complete or not happen at all
 Concurrent access by multiple users
       Concurrent access needed for performance
       Uncontrolled concurrent accesses can lead to inconsistencies
            Example: Two people reading a balance (say 100) and
             updating it by withdrawing money (say 50 each) at the same
             time
 Security problems
       Hard to provide user access to some, but not all, data
Database systems offer solutions to all the above problems
                                      1.11
                  Levels of Abstraction
 Physical level: describes how a record (e.g., instructor) is stored.
 Logical level: describes data stored in database, and the relationships
   among the data.
       type instructor = record
                  ID : string;
                  name : string;
                  dept_name : string;
                  salary : integer;
               end;
 View level: application programs hide details of data types. Views can
   also hide information (such as an employee’s salary) for security
   purposes.
                                    1.12
                       View of Data
An architecture for a database system
                                1.13
  View of Data- Three Level Architecture
An architecture for a database system
                 Instances and Schemas
 Similar to types and variables in programming languages
 Logical Schema – the overall logical structure of the database
       Example: The database consists of information about a set of
        customers and accounts in a bank and the relationship between them
            Analogous to type information of a variable in a program
 Physical schema– the overall physical structure of the database
 Instance – the actual content of the database at a particular point in time
       Analogous to the value of a variable
                                      1.15
Mapping and Data Independence
 Mapping: The process to convert a request from external
  level and data stored is called mapping. The mapping
  defines the correspondence between three levels.
 External/Conceptual Mapping
 Conceptual/Internal Mapping
Mapping and Data Independence
 Data Independence: The ability to modify a scheme
  definition in one level without affecting a scheme definition in a
  higher level is called data independence.
 Physical Data Independence – the ability to modify the
  physical schema without changing the logical schema
   Applications depend on the logical schema
   In general, the interfaces between the various levels and
    components should be well defined so that changes in some parts
    do not seriously influence others.
 Logical data Independence- The ability to change logical
  schema without changing external schema is called logical data
  independence. E.g by adding or removing attributes , tables etc.
Architecture of DBMS
        1.18
                      Internal Schema
 Lowest level of Abstraction and has knowledge of both h/w and s/w.
 Defines how data physically stored in database.
 Also called Physical Schema
 Location
 Name
 Format
                                  1.19
                    Conceptual Schema
 It deals with the modeling of whole database.
 Don’t know how and where the data is stored but knows “WHAT
    DATA IS STORED”.
    The users of this level are not concerned with how these logical data
    structures will be implemented at the physical level, rather they just
    are concerned about what information is to be kept in the database.
 Example When we use the Describe Command.
                                     1.20
                       External Schema
 It is very close to users and is the highest level of Abstraction.
 Allows to see only the data of interest to them.
 Users – Application programmers or end-users.
 Any no. of external views – external schema.
                                      1.21
             Types of Database Models
 A Database model defines the logical design and structure of a database
  and defines how data will be stored, accessed and updated in a database
  management system
 A collection of tools for describing
    Data
    Data relationships
    Data semantics
    Data constraints
    Types of Data Models
 Hierarchical Model
 Network Model
 Entity-relationship Model
 Relational Model
 Object-based data models (Object-oriented and Object-relational)
 Semistructured data model (XML)
                                    1.22
                     Hierarchical Model
 This database model organizes data into a tree-like-structure, with a
   single root, to which all the other data is linked. The hierarchy starts
   from the Root data, and expands like a tree, adding child nodes to the
   parent nodes.
 In hierarchical model, data is organized into tree-like structure with
   one-to-many relationship between two different types of data, for
   example, one department can have many courses, many professors
   and of-course many students
                                     1.23
Hierarchical Model
       1.24
                        Network Model
 This is an extension of the Hierarchical model. In this model data is
   organized more like a graph, and are allowed to have more than one
   parent node.
 In this database model data is more related as more relationships are
   established in this database model. Also, as the data is more related,
   hence accessing the data is also easier and fast. This database model
   was used to map many-to-many data relationships.
                                    1.25
Network Model
    1.26
              Entity-Relationship Model
 In this database model, relationships are created by dividing object of
   interest into entity and its characteristics into attributes.
 Different entities are related using relationships.
 E-R Models are defined to represent the relationships into pictorial
   form to make it easier for different stakeholders to understand.
 This model is good to design a database, which can then be turned
   into tables in relational model.
                                       1.27
Entity-Relationship Model
           1.28
                       Relational Model
 In this model, data is organized in two-dimensional tables and the
   relationship is maintained by storing a common field.
 The basic structure of data in the relational model is tables. All the
   information related to a particular type is stored in rows of that table.
 Hence, tables are also known as relations in relational model.
                                      1.29
Relational Model
      1.30
                 Object-Relational Data Models
 Relational model: flat, “atomic” values
 Object Relational Data Models
       Extend the relational data model by including object orientation and
        constructs to deal with added data types.
       Allow attributes of tuples to have complex types, including non-atomic
        values such as nested relations.
       Preserve relational foundations, in particular the declarative access to
        data, while extending modeling power.
       Provide upward compatibility with existing relational languages.
                                          1.31
                       Semistructured Data Model
 Permits the specification of data where individual data items of the
   same type have different set of attributes.
 XML(Extensible Mark up Language) is used to represent semi
   structured data.
                                             1.32
                                 RDBMS
 A Relational Database Management System is the DBMS that is
   based on the relational model.
 It stores the data in the form of related tables. A table is a collection of
   related data entries and it consists of columns and rows.
 RDBMS is the basis for SQL, and for all modern database systems
   such as:MS SQL Server, IBM DB2, Oracle, MySQL, Microsoft Access.
                                      1.33
                                SQL
 SQL stands for Structured Query Language.
 It is used to access and manipulate database.
What Can SQL do?
 SQL can execute queries against a database
 SQL can retrieve data from a database
 SQL can insert records in a database
 SQL can update records in a database
 SQL can delete records from a database
 SQL can create new databases
 SQL can create new tables in a database
                                  1.34
1.35
                                  DDL
 DDL is the Data Definition Language, which deals with database
   schemas and descriptions, of how the data should reside in the
   database.
 CREATE - to create a database and its objects like (table, index,
   views, store procedure, function, and triggers)
 ALTER - alters the structure of the existing database
 DROP - delete objects from the database
 TRUNCATE - remove all records from a table, including all spaces
   allocated for the records are removed
 COMMENT - add comments to the data dictionary
 RENAME - rename an object
                                    1.36
                                 DML
 DML is the Data Manipulation Language which deals with data
   manipulation and includes most common SQL statements such
   SELECT, INSERT, UPDATE, DELETE, etc., and it is used to store,
   modify, retrieve, delete and update data in a database.
 SELECT - retrieve data from a database
 INSERT - insert data into a table
 UPDATE - updates existing data within a table
 DELETE - Delete all records from a database table
 CALL - call a PL/SQL or Java subprogram
                                      1.37
                                DCL
 DCL is the Data Control Language which includes commands such as
   GRANT and mostly concerned with rights, permissions and other
   controls of the database system.
 GRANT - allow users access privileges to the database
 REVOKE - withdraw users access privileges given by using the
   GRANT command.
                                  1.38
                                    TCL
 TCL is the Transaction Control Language which deals with a
   transaction within a database.
 COMMIT - commits a Transaction
 ROLLBACK - rollback a transaction in case of any error occurs.
   Restores database to original state since the last COMMIT command
   in transactions
 SAVEPOINT - to rollback the transaction making points within groups.
 SET TRANSACTION - specify characteristics of the transaction
                                    1.39
    Database Access from Application Program
   SQL does not support actions such as input from users, output to
    displays, or communication over the network.
   Such computations and actions must be written in a host language, such
    as C/C++, Java or Python, with embedded SQL queries that access the
    data in the database.
   Application programs -- are programs that are used to interact with the
    database in this fashion.
                                      1.40
                          Database Design
The process of designing the general structure of the database:
     Logical Design – Deciding on the database schema. Database design
      requires that we find a “good” collection of relation schemas.
          Business decision – What attributes should we record in the
           database?
          Computer Science decision – What relation schemas should we
           have and how should the attributes be distributed among the
           various relation schemas?
     Physical Design – Deciding on the physical layout of the database
                                       1.41
                 Overall Database Structure
   A database system is partitioned into modules that deal with each of the
    responsibilities of the overall system.
   The functional components of a database system can be divided into
        The storage manager,
        The query processor component,
                                       1.42
   Database Architecture
(Centralized/Shared-Memory)
            1.43
                            Storage Manager
   A program module that provides the interface between the low-level data
    stored in the database and the application programs and queries
    submitted to the system.
   The storage manager is responsible to the following tasks:
        Interaction with the OS file manager
        Efficient storing, retrieving and updating of data
   The storage manager components include:
        Authorization and integrity manager: Tests for satisfaction of integrity
         constraints and checks the authority of users to access data
        Transaction manager: Ensures that database remains in a consistent
         state despite system failures and concurrent transaction processing
        File manager: Allocation of space on disk storage and data structures
         used to represent information stored on disk
        Buffer manager: Responsible for fetching data from disk storage into
         main memory.
                                         1.44
                     Storage Manager (Cont.)
   The storage manager implements several data structures as part of the
    physical system implementation:
        Data files -- store the database itself
        Data dictionary -- stores metadata about the structure of the
         database, in particular the schema of the database.
        Indices -- can provide fast access to data items. A database index
         provides pointers to those data items that hold a particular value.
                                          1.45
                             Query Processor
   The query processor components include:
        DDL interpreter -- interprets DDL statements and records the
         definitions in the data dictionary.
        DML compiler -- translates DML statements in a query language into
         an evaluation plan consisting of low-level instructions that the query
         evaluation engine understands.
             The DML compiler performs query optimization; that is, it picks
              the lowest cost evaluation plan from among the various
              alternatives.
        Query evaluation engine -- executes low-level instructions generated
         by the DML compiler.
                                         1.46
                        Query Processing
1. Parsing and translation
2. Optimization
3. Evaluation
                              1.47
                                  Query Processing (Cont.)
 Alternative ways of evaluating a given query
       Equivalent expressions
       Different algorithms for each operation
 Cost difference between a good and a bad way of evaluating a
   query can be enormous
 Need to estimate the cost of operations
       Depends critically on statistical information about relations
        which the database must maintain
       Need to estimate statistics for intermediate results to compute
        cost of complex expressions
                                              1.48
                      Database Applications
Database applications are usually partitioned into two or three parts
       Two-tier architecture -- the application resides at the client machine,
        where it invokes database system functionality at the server machine
       Three-tier architecture -- the client machine acts as a front end and
        does not contain any direct database calls.
            The client end communicates with an application server, usually
             through a forms interface.
            The application server in turn communicates with a database
             system to access data.
                                        1.49
Two-tier and three-tier architectures
                 1.50
Database Users and Administrators
          Database
              1.51
                     Database Users
 Naïve Users: are unsophisticated users who interact with the system
  by invoking one of the application programs that have been written
  previously
 Application Programmers: are computer professionals who write
  application programs.
 Sophisticated Users: These users interact with the database without
  writing programs. Instead they form their requests in database query
  language.
 Database Administrator: A person who has central control over the
  system is called a database administrator (DBA)
                                  1.52
                     Database Administrator
A person who has central control over the system is called a database
administrator (DBA). Functions of a DBA include:
     Schema definition
     Storage structure and access-method definition
     Schema and physical-organization modification
     Granting of authorization for data access
     Routine maintenance
          Periodically backing up the database
          Ensuring that enough free disk space is available for normal
           operations, and upgrading disk space as required
          Monitoring jobs running on the database
                                       1.53
                  History of Database Systems
   1950s and early 1960s:
        Data processing using magnetic tapes for storage
             Tapes provided only sequential access
        Punched cards for input
   Late 1960s and 1970s:
        Hard disks allowed direct access to data
        Network and hierarchical data models in widespread use
        Ted Codd defines the relational data model
             Would win the ACM Turing Award for this work
             IBM Research begins System R prototype
             UC Berkeley (Michael Stonebraker) begins Ingres prototype
             Oracle releases first commercial relational database
        High-performance (for the era) transaction processing
                                         1.54
        History of Database Systems (Cont.)
 1980s:
    Research relational prototypes evolve into commercial systems
       SQL becomes industrial standard
    Parallel and distributed database systems
       Wisconsin, IBM, Teradata
    Object-oriented database systems
 1990s:
    Large decision support and data-mining applications
    Large multi-terabyte data warehouses
    Emergence of Web commerce
                                    1.55
         History of Database Systems (Cont.)
   2000s
      Big data storage systems
        Google BigTable, Yahoo PNuts, Amazon,
        
       “NoSQL” systems.
    Big data analysis: beyond SQL
       Map reduce and friends
 2010s
    SQL reloaded
       SQL front end to Map Reduce systems
       Massively parallel database systems
       Multi-core main-memory databases
                                  1.56
End of Week 1&2
       1.57