Introduction to Database and Transactions

Embed Size (px)

Citation preview

  • 7/29/2019 Introduction to Database and Transactions

    1/24

    Network

    Model

    Basic Modeling construct is Set

    Set contains Owner Record type, aSet Name, a member Record Type

    member Record Type achieves Manyto many Relation

    Owner Record type may be memberof Owner in another set

    Data Model is Simple N/W

    Links and Intersections record Typesmay exist and sets between them

    Complete N/W of Relationship isrepresented by several pair wise sets

    In Each set some Record Types are

    Owner and one or more recordtypes are Members

    Usually set defines 1:M relationship,1:1 also permitted

    In 1971, conference on

    Data Systems Language

    (CODASYL) defined N/WModel

    Based on Mathematical

    Set Theory

    Permits Modeling of

    Many-to-manyRelationship in data

    Copyright SevenPeaks Academy

  • 7/29/2019 Introduction to Database and Transactions

    2/24

    DATABASE LANGUAGES

    Data Definition Language (DDL)

    DDL is to Specify the Database

    Schema, Create, destroy

    database and database object,

    Storage Structure, access

    method statements

    Commands for Data

    Administrators

    Provides facility of Constraintslike integrity constraints,

    domain constarints

    Data Manipulation Language(DML) /Query Language

    DML to express databasequeries and updates

    Allows the users to manipulate

    data as organized byappropriate data model

    Used to retrieve, Insert, &modify database information

    Two types: 1. Procedural &

    2. Non Procedural Procedural DML: What data r

    needed and how to get thatdata.

    Copyright SevenPeaks Academy

    Copyright SevenPeaks Academy

  • 7/29/2019 Introduction to Database and Transactions

    3/24

    DML

    DML to express database queries and updates

    Allows the users to manipulate data as organized by appropriate datamodel

    Used to retrieve, Insert, & modify database information

    Two types: 1. Procedural &2. Non Procedural

    Procedural DML: What data r needed and how to get that data

    Used to transfer cause data between a run unit & database

    It relies on the host language for framework to provide proceduralactivities required to manipulate.

    Basic DML Commands are: SELECTSELECT *INSERTUPDATEDELETEMERGE

    Copyright SevenPeaks Academy

    Copyright SevenPeaks Academy

  • 7/29/2019 Introduction to Database and Transactions

    4/24

    DCL Domain Constraints:

    * Domain-Set of Possible Values for each attribute associated with an entity set.* Specify important constraints that each instance of relation must satisfy

    Referential Integrity:

    Property of data which, when satisfied, requires every value of one attribute(column) of

    relation (table) to exists as a value of another attribute in a different (or the same)

    relation (Table)

    Assertions: Condition that database must always satisfy

    e.g. Domain Constraint and Referential Integrity

    Authorization: Read Authorization

    Insert Authorization

    Update Authorization

    Delete Authorization DDL Commands: CREATE DATABASE & TABLE

    USE

    ALTER

    ADD

    DROP DATABASE & TABLE

    Copyright SevenPeaks Academy

    Copyright SevenPeaks Academy

  • 7/29/2019 Introduction to Database and Transactions

    5/24

    DATABASE DESIGN Process of producing a detailed data model of Database

    contains all logical and physical design choices and Physicalstorage parameter

    Fully attributed data model contains detailed attributes for

    each entity.

    Design carried out by1. find the relationship between different Data elements,

    2. Superimpose a logical structure upon data on the basis of

    these relationship

    To design information s/m that is based in database, the

    conceptual data model is mapped to logical data model

    (relational model); this in turn mapped to a physical model

    during physical design. Both of these stages are referred as

    Physical Design.

    Copyright SevenPeaks Academy

    Copyright SevenPeaks Academy

  • 7/29/2019 Introduction to Database and Transactions

    6/24

    Entity-Relationship Model This model is used during Requirement Analysis stage of

    Information System Design. Entity - a thing which is recognized as being capable of an

    independent existence & uniquely identified.

    E.g. Car, house etc. It can be set as noun

    Relationship -How two or more entities r related to one another. It

    can be set as Verb, linking two or more nouns.

    E.g. an owns relationship between Company and a computer,

    a performs relationship between an artist and a song.

    Attributes Entity and Relationship can both have attributes.

    E.g. An employee entity might have an Employee Id. attributeProvedrelationship may have a Date attribute

    Every Entity must have a minimal set of uniquely identified

    attributes, called Entitys Primary Key

    Continue.

    Copyright SevenPeaks Academy

    Copyright SevenPeaks Academy

  • 7/29/2019 Introduction to Database and Transactions

    7/24

    Entity-Relationship Model

    Diagrammatic conventions are used called EntityRelationship Diagrams (ERDs)

    Entity Set -> Rectangles

    Relationship Set -> Diamonds

    Attributes -> Ovals connected with Lines

    If Entity set participates in a relationship set, theyare connected with a line.

    ERDs dont show single entities or single instanceof relations.

    Continue

    Copyright SevenPeaks Academy Copyright SevenPeaks Academy

  • 7/29/2019 Introduction to Database and Transactions

    8/24

    Entity-Relationship

    Model

    A Double line : A participationconstraints i.e. totality orsurjectivity:

    An arrow from entity set to

    relationship set : A keyconstraint, i.e. injectivity

    A thick line indicates both, i.e.

    bijective An underlined name of an

    attribute indicates that is a key

    Entity Set ->Rectangles

    Relationship Set-> Diamonds

    Attributes ->

    Ovalsconnected with

    Lines

    Copyright SevenPeaks Academy

    cardinality constraints

    expressed by ERDs

  • 7/29/2019 Introduction to Database and Transactions

    9/24

    Normalization Normalization: Normalization is the process of efficiently organizing

    data in a database.

    There are two goals of Normalization process:1. Eliminating Redundant Data2. Ensuring data dependencies make sense

    There are five normal forms through which we can normalize the

    database. These forms are as following:1. First Normal Form or 1NF2. Second Normal Form or 2NF3. Third Normal Form or 3NF4. Fourth Normal Form or 4NF5. Fifth Normal Form or 5NF

    Out of these five normal forms only first three are used in practical.4NF used occasionally and 5NF is used veryrarely.

    Copyright SevenPeaks Academy Copyright SevenPeaks Academy

    Continue.

  • 7/29/2019 Introduction to Database and Transactions

    10/24

    First Normal Form (1NF) :

    First normal forms (1NF) sets the very basic rules

    for an organized database:1. Eliminate duplicate columns from the Same Table

    2. Create Separate table for each group of related dataand identify each row with the unique column orset of columns (the primary key)

    Second Normal Form (2NF):Second Normal Form (2NF) further addresses theconcept of removing the duplicate data. This can beachieved by following techniques,

    1. Meet all requirement s of 1NF

    2. Remove subsets of Data that apply to multiple rowsof a table and place them in separate tables

    3. Create relationship between these new tables and theirpredecessors through the use of Foreign Key

    Copyright SevenPeaks Academy

    Normalization

    Copyright SevenPeaks Academy

    Continue.

  • 7/29/2019 Introduction to Database and Transactions

    11/24

    Third Normal Form (3NF) :

    3NF goes one step further;1. Meet all requirement s of 2NF2. Remove columns that are not dependent

    upon the primary key

    Fourth Normal Form (4NF) :Meet all requirement s of 3NF

    A Relation is in 4NF if it has no multi-valueddependencies.

    Normalization guidelines are cumulative. For thedatabase to be in 2NF, it must full fill criteria of 1NF

    Copyright SevenPeaks Academy

    Normalization

    Copyright SevenPeaks Academy

  • 7/29/2019 Introduction to Database and Transactions

    12/24

    Data Storage and Querying

    DS Partitioned in to modules with each of the

    separate Responsibilities.

    Functional Components of DS are partitioned

    into Storage Manager (SM) and Query

    Processor Components (QP) SM is imp as database requires a large amt of

    space for Storing data.

    QP is imp as it helps DS to simplify and allowsthe system to access data

    Copyright SevenPeaks Academy Copyright SevenPeaks Academy

    Continue.

  • 7/29/2019 Introduction to Database and Transactions

    13/24

    Storage Manager (SM): Provide the interface between:1. file Manager2. Buffer Manager3. Data Integrity Manager4. Transaction Manager.

    File Manager: To Manage Disk Space for the Storageand Data Structure used for Storing information.

    Buffer Manager: Fetching data from Disk Storage intomain memory and decides what data are to be cachedin to memory

    Data Integrity Manager: Check the IntegrityConstraints, & authority of users to access the data.

    Transaction Manager: ensures that database remains ina consistent and in the correct state.

    Copyright SevenPeaks Academy Copyright SevenPeaks Academy

    Data Storage and QueryingStorage Manager (SM)

    Continue.

  • 7/29/2019 Introduction to Database and Transactions

    14/24

    SM implements several data structures as apart of the Physical system implementation:

    Some of them are File System, Data Dictionary,

    Indices

    File System: Stores data itself

    Data Dictionary: Stores metadata of Database

    i.e. Structure of Database in particular Schema Indices: Used to provide fast access to

    database.

    Copyright SevenPeaks Academy

    Data Storage and QueryingStorage Manager

    Copyright SevenPeaks Academy

    Continue.

  • 7/29/2019 Introduction to Database and Transactions

    15/24

    Query Processor Components are:

    1. DDL Interpreter2. DML Compiler

    3. Query Evaluation Engine

    DDL Interpreter:

    1. Interprates DDL Statements and records defn in the data dictionary. DML Compiler:

    1. Translates DML Statemt in a query Language into a evaluation planand performs query Optimization.

    2. Evaluation plan consists of Low-Level instructions that the QueryEvaluation Engine understand.

    3. DML Compiler Also performs Query Optimization by picking thelowest cost evaluation plan among the alternatives

    Query Evaluation Engine: Executes the low level instructionsgenerated by DML Compiler.

    Copyright SevenPeaks Academy Copyright SevenPeaks Academy

    Data Storage and QueryingQuery Processor:

  • 7/29/2019 Introduction to Database and Transactions

    16/24

    Transaction Management (TM) in DBMS A Database Transaction Management ideally guarantees

    ACID property

    Ensures Data integrity i.e. avoid Concurrent user accessto data or Faults tolerance.

    Through TM, DBMS maintain integrity by not allowingmore than one user to update same record at the Same

    time. (Integrity Constraints) Through TM, DBMS can help to prevent duplicate record

    via Unique Index Constraint (Unique key Constraints)

    Transaction Processing allows multiple individual

    operatns to be linked together a single, individual trann.

    It ensures that either all operatn in a transaction arecompleted without error or none of then are.

    Copyright SevenPeaks Academy Copyright SevenPeaks Academy

    Continue.

  • 7/29/2019 Introduction to Database and Transactions

    17/24

    If some opertn are completed but error occur when others

    are attempted, the transaction processing system RollBack all of the operation of the transaction (includingsuccessful one also)

    If all operations of Transactions are completedsuccessfully, the transaction is committed by the systemand all changes to the database are made permanent, andthis transaction cant rollback.

    Transaction Processing guards against H/W and S/W errorsthat might leave a transaction partially completed

    Transactions are processed in a strict Chronological Order.i.e. if n+1th transaction deals with the same portion ofdatabase as nth transaction dealing, transaction n+1 willnot begin until transaction n is committed.

    Copyright SevenPeaks Academy Copyright SevenPeaks Academy

    Transaction Management (TM) in DBMS

    Continue.

  • 7/29/2019 Introduction to Database and Transactions

    18/24

    Before any transaction is committed, all other

    transaction affecting the same part of theDatabase must also be committed.

    Transaction Management component ensure

    that the database remains in a consistent state

    despite system failure and transaction failures.

    Questions: Why Transaction Management isimportant in DBMS and how we are achieving it

    in DBMS?

    Copyright SevenPeaks Academy Copyright SevenPeaks Academy

    Transaction Management (TM) in DBMS

  • 7/29/2019 Introduction to Database and Transactions

    19/24

    Data Mining and Analysis

    Data Mining is a process of extracting patternsfor Data

    The related terms are data dredging, data

    fishing, & data snooping. Four tasks of data Mining:

    1.Clustering

    2. Classification3. Regression4. Association Rule Learning

    Copyright SevenPeaks Academy Copyright SevenPeaks Academy

    Continue.

  • 7/29/2019 Introduction to Database and Transactions

    20/24

    Data Mining and Analysis

    Clustering: Task of discovering Groups and structuresin data that r in some way or another Similar,without know structure of database.

    Classification: Task of generalizing known structure toapply to new data.

    Regression: Attempt to find a function which modelsthe data with the least error.

    Association Rule Learning: Searches for relationshipbetween variables.

    Question: What is mean by Data Mining and what arethe tasks of Data Mining?

    Copyright SevenPeaks Academy Copyright SevenPeaks Academy

    Database Architecture:

  • 7/29/2019 Introduction to Database and Transactions

    21/24

    Database Architecture:

    Copyright SevenPeaks Academy Copyright SevenPeaks Academy

    Simple UserApplication

    Programmer

    Sophisticated

    User(Analyser)

    Database

    Administrator

    Application

    Interface

    Application

    ProgramQuery Tools

    Administration

    tools

    Application Program

    Object Code

    Query Evaluation engine

    DML Compiler and

    Organizer

    DDL InterpreterDML QueryCompiler and Linker

    Buffer Manager File ManagerAuthorization & Integrity

    ManagerTransaction Manager

    Data IndicesData Dictionary

    Statistical Data

    User Write User User

    Query Processor

    Storage Manager

    Disk Package

  • 7/29/2019 Introduction to Database and Transactions

    22/24

    Database Architecture The architecture of Database system in depends

    on the underlying Computer System on which the

    database is running. Accordingly the architecture is divided into:

    1. Centralized2. Client-Server

    3. Parallel4. Distributed

    Two-tier Architecture:* Application is partitioned into components that

    resides on client machine* Client Machine directly invoke database systemat server level through Query Language Statemt.

    Copyright SevenPeaks Academy Copyright SevenPeaks Academy

    Continue.

  • 7/29/2019 Introduction to Database and Transactions

    23/24

    Three-Tier Architecture:

    * Client Machine acts as merely a front-end anddoes not contain any direct call.

    * Usually the client end communicates with the

    application server through forms interface

    Copyright SevenPeaks Academy Copyright SevenPeaks Academy

    Database Architecture

    User User

    ApplicationApplication

    Client

    Application

    Server

    Database System

    Database System

    Client

    Server

    T

    w

    o

    -

    Ti

    e

    r

    A

    r

    c

    h

    i

    t

    ec

    t

    u

    r

    e

    T

    h

    r

    e

    e

    -

    T

    i

    e

    r

    A

    r

    c

    h

    i

    t

    e

    c

    t

    u

    r

    e

  • 7/29/2019 Introduction to Database and Transactions

    24/24

    Database Users and Administrators

    Database User:

    * Four Types:1. Nave Users (simple User)

    2. Application Programmer

    3. Sophisticated Users4. Specialized Users

    Copyright SevenPeaks Academy Copyright SevenPeaks Academy