dbms 2222222

Upload: rahul-chopra

Post on 08-Apr-2018

230 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/7/2019 dbms 2222222

    1/41

  • 8/7/2019 dbms 2222222

    2/41

    Chapter 1. IntroductionChapter 1. Introduction

    1.1. Basic Concepts.Basic Concepts.What is Data? What is Data?What is Database? What is Database?What is Database Management System? What is Database Management System?

    2.2. Purpose & Advantages of DBMS.Purpose & Advantages of DBMS.

    3.3. Data Models.Data Models.

    4.4. DBMS ArchitectureDBMS ArchitectureThree Level Architecture Three Level ArchitectureOverall ArchitectureOverall Architecture

    5.5. Various Components of DBMS. Various Components of DBMS.

  • 8/7/2019 dbms 2222222

    3/41

    1.1. Basic ConceptsBasic Concepts : :--

    What is Data? What is Data?

    Data Data isis aa collectioncollection of of factsfacts fromfrom which whichconclusionconclusion maymay bebe drawndrawn..

    InIn computercomputer science,science, data data isis anythinganything inin aa formformsuitablesuitable forfor useuse with with aa computercomputer. . DataData isis oftenoftendistinguisheddistinguished fromfrom programs programs. . A A program program isis aa setsetof of instructionsinstructions thatthat detaildetail aa task task forfor thethe computercomputertoto perform perform.. InIn thisthis sense,sense, datadata isis thusthus everythingeverythingthatthat isis notnot program program codecode..

    Con t.Con t.

  • 8/7/2019 dbms 2222222

    4/41

    What is Database? What is Database?

    A

    A databasedatabase isis aa collectioncollection of of datadata thatthat isis organizedorganizedsoso thatthat itsits contentscontents cancan easilyeasily bebe accessed,accessed, managed,managed,andand updatedupdated. .

    A

    A databasedatabase isis aa collectioncollection of of data,data, typicallytypicallydescribingdescribing thethe activitiesactivities of of oneone oror moremore relatedrelatedorganizationsorganizations. .

    Database

    Database isis aa structuredstructured collectioncollection of of recordsrecords orordatadata thatthat isis storedstored inin aa computercomputer systemsystem..

    ContCont

  • 8/7/2019 dbms 2222222

    5/41

    What is Database Ma n ageme n t System? What is Database Ma n ageme n t System?

    A A DatabaseDatabase ManagementManagement SystemSystem (DBMS),(DBMS), oror simplysimply aaDatabaseDatabase SystemSystem (DBS)(DBS) consistconsist of of ::

    A A collectioncollection of of interrelatedinterrelated andand persistent persistent datadata (usually(usuallyreferredreferred toto asas thethe databasedatabase (DB))(DB))..

    A A setset of of applicationapplication programs programs usedused toto access,access, updateupdate andandmanagemanage thatthat datadata (which(which formform thethe datadata managementmanagementsystemsystem (MS))(MS))..

    The The goalgoal of of aa DBMSDBMS isis toto provide provide anan environmentenvironment thatthat isis

    bothboth convenientconvenient andand efficientefficient toto useuse inin :: RetrievingRetrieving informationinformation fromfrom thethe databasedatabase. . StoringStoring informationinformation intointo thethe databasedatabase. .

    Cont.Cont.

  • 8/7/2019 dbms 2222222

    6/41

    DatabasesDatabases areare usually usually designeddesigned toto managemanage largelarge bodiesbodies of of

    informationinformation.. This This involvesinvolves DefinitionDefinition of of structuresstructures forfor informationinformation storagestorage (data(data

    modeling)modeling).. ProvisionProvision of of mechanismsmechanisms forfor thethe manipulationmanipulation of of

    informationinformation (file(file andand systemssystems structure,structure, query query processing)processing)..

    ProvidingProviding forfor thethe safety safety of of informationinformation inin thethe

    databasedatabase (crash(crash recovery recovery andand security)security).. Concurrency Concurrency controlcontrol if if thethe systemsystem isis sharedshared by by usersusers..

    Count.Count.

  • 8/7/2019 dbms 2222222

    7/41

    2.12.1 Purpose of DBMS :Purpose of DBMS :- -

    In the early days, database applications were built directly on top of filesystems

    Drawbacks of using file systems to store data:

    1. Data redundancy and inconsistency- Multiple file formats, duplication of information in different files

    2. Difficulty in accessing data- Need to write a new program to carry out each new task

    3. Data isolation multiple files and formats

    4. 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

    CountCount

  • 8/7/2019 dbms 2222222

    8/41

    2.12.1 Purpose of DBMSPurpose of DBMS : :-- (Count)(Count)

    5 . Atomicity of updates

    - Failures may leave database in an inconsistent state with partialupdates carried out

    - Example: Transfer of funds from one account to another should either `complete or not happen at all

    6. Concurrent access by multiple users

    - Concurrent accessed needed for performance- Uncontrolled concurrent accesses can lead to inconsistencies

    Example: Two people reading a balance and updating it at the same time

    7. Security problems

    - Hard to provide user access to some, but not all, data

  • 8/7/2019 dbms 2222222

    9/41

    2.22.2 Advantages of DBMS Advantages of DBMS : :--

    DatabaseDatabase ManagementManagement SystemSystem (DBMS)(DBMS) aidsaids ininstorage,storage, control,control, manipulationmanipulation andand retrievalretrieval of of datadata..

    This This articlearticle listslists thethe advantagesadvantages of of databasedatabasemanagementmanagement systemssystems. .DatabaseDatabase isis aa softwaresoftware program, program, usedused toto store,store, delete,delete,updateupdate andand retrieveretrieve datadata.. A A databasedatabase cancan bebe limitedlimited totoaa singlesingle desktopdesktop computercomputer oror cancan bebe storedstored inin largelargeserverserver machines,machines, likelike thethe IBMIBM MainframeMainframe. . There There areare

    various various databasedatabase managementmanagement systemssystems availableavailable inin thethemarketmarket. . SomeSome of of themthem areare Sybase,Sybase, MicrosoftMicrosoft SQLSQLServer,Server, OracleOracle RDBMS,RDBMS, PostgreSQL,PostgreSQL, etcetc..

    ContCont

  • 8/7/2019 dbms 2222222

    10/41

    The The databasedatabasemanagementmanagement systemssystems areare warehouses warehouses of of information,information, where wherelargelarge amountamount of of datadata cancan bebestoredstored.. The The commoncommon examplesexamples inincommercialcommercial applicationsapplications areareinventoryinventory data,data, personnel personnel data,data, etcetc..ItIt oftenoften happenshappens thatthat aa commoncommonmanman usesuses aa databasedatabase managementmanagementsystem,system, without without eveneven realizing,realizing,thatthat itit isis beingbeing usedused.. The The bestbestexamplesexamples forfor thethe

    samesame would would bebe thethe addressaddress book book of of aa cellcell phone, phone, digitaldigital diaries,diaries, etcetc..BothBoth thesethese equipmentsequipments storestore datadatainin theirtheir internalinternal databasedatabase. .

    ContCont

    1. Data Warehouses

  • 8/7/2019 dbms 2222222

    11/41

    2 . Defining Attributes :-

    The unique data field in a table is assigned a primarykey. The primary key helps in the identification of

    data. It also checks for duplicates within the sametable, thereby reducing data redundancy. There aretables, which have a secondary key in addition to the

    primary key. The secondary key is also called

    'foreign key'. The secondary key refers to the primary key of another table, thus establishing arelationship between the two tables.

    Count

  • 8/7/2019 dbms 2222222

    12/41

    3 . Systematic Storage :-

    The data is stored in the form of tables. The tableconsists of rows and columns. The primary andsecondary key helps to eliminate data redundancy,enabling systematic storage of data.

    4. Changes to schema :-

    The table schema can be changed and it is not platformdependent. Therefore, the tables in the system can be

    edited to add new columns and rows without hamperingthe applications, which depend on that particular database.

    Count

  • 8/7/2019 dbms 2222222

    13/41

    5 . No Language Dependence :-

    The database management systems are not language dependent.Therefore, they can be used with various languages and on variousplatforms.

    6. Table Joins :-

    The data in two or more tables can be integrated into a single table.This enables to reduce the size of the database and also helps ineasy retrieval of data.

    7. Multiple Simultaneous Usage :-

    The database can be used simultaneously by a number of users.Various users can retrieve the same data simultaneously. The datain the database can also be modified, based on the privilegesassigned to users.

    Count

  • 8/7/2019 dbms 2222222

    14/41

    8 . Data Security :-

    Data is the most important asset. Therefore, there is a need for datasecurity. Database management systems help to keep the datasecured.

    9. Privileges :-

    Different privileges can be given to different users. For example,some users can edit the database, but are not allowed to delete thecontents of the database.

    10. Abstract View of Data and Easy Retrieval :-

    DBMS enables easy and convenient retrieval of data. A databaseuser can view only the abstract form of data; the complexities of theinternal structure of the database are hidden from him. The datafetched is in user friendly format.

    Count

  • 8/7/2019 dbms 2222222

    15/41

    11. Data Consistency :-

    Data consistency ensures a consistent view of data toevery user. It includes the accuracy, validity and integrityof related data. The data in the database must satisfycertain consistency constraints, for example, the age of a candidate appearing for an exam should be of number data type and in the range of 2 0-25 . When the databaseis updated, these constraints are checked by thedatabase systems.

  • 8/7/2019 dbms 2222222

    16/41

    3.3. Data ModelsData Models : :-- A Collection of tools for describing : A Collection of tools for describing :

    DataDataData RelationshipData RelationshipAdd Semantics Add SemanticsData ConstraintsData Constraints

    Relational ModelRelational Model Entity Relationship Model (for Database Design)Entity Relationship Model (for Database Design) Object base Data Model (for ObjectObject base Data Model (for Object- -Oriented)Oriented) Semistructured Data Model (XML)Semistructured Data Model (XML)

    Other Older Models :Other Older Models :Network ModelNetwork ModelHierarchical ModelHierarchical Model

  • 8/7/2019 dbms 2222222

    17/41

  • 8/7/2019 dbms 2222222

    18/41

    A hierarchical database consists of the following:1. It contains nodes connected by branches.

    2. The top node is called the root.3. If multiple nodes appear at the top level, the nodes are

    called root segments.

    4. The parent of nodenx

    is a node directly abovenx

    andconnected to nx by a branch.5. Each node (with the exception of the root) has exactly

    one parent.

    6. The child of node nx is the node directly below nx andconnected to nx by a branch.

    7. One parent may have many children.

  • 8/7/2019 dbms 2222222

    19/41

    By introducing data redundancy, complexnetwork structures can also be represented

    as hierarchical databases. This redundancyis eliminated in physical implementation byincluding a 'logical child'. The logical childcontains no data but uses a set of pointers

    to direct the database management systemto the physical child in which the data isactually stored. Associated with a logicalchild are a physical parent and a logicalparent. The logical parent provides analternative (and possibly more efficient)path to retrieve logical child information.

  • 8/7/2019 dbms 2222222

    20/41

    3.6 Network Data Model :-T his model organizes data using two fundamental constructs,called records and sets. Records contain fields, and setsdefine one-to-many relationships between records: oneowner, many members.

  • 8/7/2019 dbms 2222222

    21/41

    Access to the database was not via SQL query strings, butby a specific set of API's, typically for FIND, CREATE,

    READ, UPDATE and DELETE.Each API would only access a single table (dataset), so it

    was not possible to implement a JOIN which would returndata from several tables.

    It was not possible to provide a variable WHERE clause. The only selection mechanism available was read all entries (a full table scan). read a single entry using a specific primary key. read all entries on a child table which were associated with a

    selected entry on a parent table

    Any further filtering had to be done within the applicationcode.

  • 8/7/2019 dbms 2222222

    22/41

    It was not possible to provide an ORDER BY clause. Data was presented in the order in which itexisted in the database. This mechanism could betuned by specifying sort criteria to be used wheneach record was inserted, but this had several

    disadvantages: Only a single sort sequence could be defined for eachpath (link to a parent), so all records retrieved on thatpath would be provided in that sequence.

    It could make inserts rather slow when attempting toinsert into the middle of a large collection, or where atable had multiple paths each with its own set of sortcriteria.

  • 8/7/2019 dbms 2222222

    23/41

  • 8/7/2019 dbms 2222222

    24/41

    1.1. Enterprise DBMS :Enterprise DBMS :- -

    ItIt isis designeddesigned for for scalabilityscalability andand highhigh performanceperformance. . ItItmustmust bebe capablecapable of of supportingsupporting veryvery largelarge databases,databases, a alargelarge number number of of concurrentconcurrent users,users, andand multiplemultiple typestypes of of applicationsapplications. . TheThe enterpriseenterprise DBMSDBMS willwill runrun onon aa largelarge--scalescale machine,machine, typicallytypically aa mainframemainframe or or aa highhigh--endendUnix,Unix, Linux,Linux, or or WindowsWindows NTNT machinemachine. . Furthermore,Furthermore, ananenterpriseenterprise DBMSDBMS offersoffers allall of of thethe bellsbells andand whistleswhistlesavailableavailable fromfrom thethe DBMSDBMS vendor vendor. . MultiMulti--processor processor

    support,support, supportsupport for for parallelparallel queries,queries, clustering,clustering, andandother other advancedadvanced DBMSDBMS featuresfeatures willwill bebe corecorecomponentscomponents of of anan enterpriseenterprise DBMSDBMS..

  • 8/7/2019 dbms 2222222

    25/41

    2 . Departmental DBMS :2 . Departmental DBMS :- -

    sometimessometimes referredreferred toto asas aa workgroupworkgroup DBMS,DBMS, supportssupportssmallsmall toto mediummedium sizedsized workgroupsworkgroups withinwithin anan organization,organization,andand typicallytypically runsruns onon aa Unix,Unix, Linux,Linux, or or WindowsWindows 20002000 (or (or NT)NT) server server. . TheThe dividingdividing lineline betweenbetween a a departmentaldepartmentaldatabasedatabase server server andand anan enterpriseenterprise databasedatabase server server isisgraygray. . HardwareHardware andand softwaresoftware upgradesupgrades oftenoften cancan allowallow aadepartmentaldepartmental DBMSDBMS toto tackletackle taskstasks thatthat previouslypreviously couldcouldonlyonly bebe performedperformed byby anan enterpriseenterprise DBMSDBMS.. TheThe steadilysteadily

    fallingfalling costcost of of departmentaldepartmental hardwarehardware andand softwaresoftwarecomponentscomponents further further contributescontributes toto loweringlowering TCOTCO andandhelpinghelping toto enableenable a a workgroupworkgroup environmentenvironment toto scalescale upup totoserveserve thethe enterpriseenterprise. .

  • 8/7/2019 dbms 2222222

    26/41

    3 . Personal DBMS3 . Personal DBMS ::--

    isis designeddesigned toto bebe usedused byby aa singlesingle user,user, typicallytypically onon aa lowlow--toto mediummedium- -poweredpowered PCPC platformplatform. . LotusLotus Approach, Approach,MicrosoftMicrosoft Access Access andand dBasedBase areare examplesexamples of of personalpersonaldatabasedatabase softwaresoftware. . Of Of course,course, thethe major major DBMSDBMS vendorsvendorsalsoalso marketmarket personalpersonal versionsversions of of their their moremore highhigh--poweredpoweredsolutions,solutions, PersonalPersonal OracleOracle andand DBDB22 EveryplaceEveryplace for for exampleexample. . SometimesSometimes thethe lowlow costcost of of aa personalpersonal DBMSDBMScausescauses misguidedmisguided attemptsattempts toto choosechoose a a personalpersonal DBMSDBMS

    for for aa departmentaldepartmental or or enterpriseenterprise solutionsolution. . ButBut dodo notnot bebeluredlured byby thethe lowlow costcost. . A A personalpersonal DBMSDBMS productproduct isis suitedsuitedonlyonly for for smallsmall scalescale projectsprojects andand shouldshould notnot bebe usedused totodeploydeploy multimulti--user user applicationsapplications. .

  • 8/7/2019 dbms 2222222

    27/41

    4. Mobile DBMS4. Mobile DBMS ::--

    isis aa specializedspecialized versionversion of of aa departmentaldepartmental or or enterpriseenterpriseDBMSDBMS.. ItIt isis designeddesigned toto bebe usedused byby remoteremote usersusers whowho arearenotnot usuallyusually connectedconnected to to thethe networknetwork. . TheThe mobilemobile DBMSDBMSenablesenables locallocal databasedatabase accessaccess andand modificationmodification onon aalaptoplaptop or or handheldhandheld device,device, suchsuch asas aa PalmPalm PDAPDA or or PocketPCPocketPC. . Furthermore,Furthermore, thethe mobilemobile DBMSDBMS providesprovides a amechanismmechanism for for synchronizingsynchronizing remoteremote databasedatabase changeschangestoto aa centralized,centralized, enterpriseenterprise or or departmentaldepartmental databasedatabase

    server server. .

  • 8/7/2019 dbms 2222222

    28/41

    Three Three--Level Architecture :Level Architecture :- -

    A A commonlycommonly usedused views views of of datadata approachapproach isis thethe threethree--levellevelarchitecturearchitecture suggestedsuggested byby ANSI/SPARC ANSI/SPARC (American(American NationalNationalStandardsStandards Institute/StandardsInstitute/Standards PlanningPlanning andand RequirementsRequirementsCommittee)Committee). . ANSI/SPARC ANSI/SPARC produced produced anan interiminterim reportreport inin19721972 followedfollowed byby aa finalfinal reportreport inin 19771977

    The three levels of the architecture are three different views The three levels of the architecture are three different viewsof the data:of the data:1. External - individual user view 2. Conceptual - community user view 3. Internal - physical or storage view

    Count

  • 8/7/2019 dbms 2222222

    29/41

  • 8/7/2019 dbms 2222222

    30/41

    Two-Tier Client-Server

    Client manages main business and

    data processing logic and userinterface.Server manages and controls access to

    database.

  • 8/7/2019 dbms 2222222

    31/41

    Two-Tier Client Server Architecture

  • 8/7/2019 dbms 2222222

    32/41

    Three-Tier C-S ArchitectureClient side presented two problemspreventing true scalability: Fat client, requiring considerable resources on

    client s computer to run effectively. Significant client side administration overhead.

    By 1995, three layers proposed, eachpotentially running on a differentplatform.

  • 8/7/2019 dbms 2222222

    33/41

  • 8/7/2019 dbms 2222222

    34/41

    Three-Tier C-S ArchitectureAdvantages: Thin client, requiring less expensive

    hardware. Application maintenance centralized. Easier to modify or replace one tier without

    affecting others.

    Separating business logic from databasefunctions makes it easier to implement loadbalancing.

    Maps quite naturally to Web environment.

  • 8/7/2019 dbms 2222222

    35/41

    Three-Tier Architecture

  • 8/7/2019 dbms 2222222

    36/41

    Ov erall Architecture

    Ov erall Architecture : :--

    A A DBMSDBMS isis typicallytypically runrun asas aa back back--endend serverserverinin aa (local(local oror global)global) network,network, offeringoffering servicesservicestoto clientsclients directlydirectly oror toto applicationapplication serversservers..

  • 8/7/2019 dbms 2222222

    37/41

  • 8/7/2019 dbms 2222222

    38/41

    Components of DBMS :-

    Hardware Can range from a PC to a network of computers.

    Software DBMS, operating system, network software (if

    necessary ) and also the application programs.

    Data Used by the organization and a description of this datacalled the schema.

    People

    Includes database designers, DBAs, applicationprogrammers, and end-users.

    Procedure Instructions and rules that should be applied to the

    design and use of the database and DBMS.

  • 8/7/2019 dbms 2222222

    39/41

    Data Definition LanguageData Definition Language : :-- (DDL)(DDL)TheThe DataData DefinitionDefinition LanguageLanguage (DDL)(DDL) isis usedused toto createcreate andand destroydestroydatabasesdatabases andand databasedatabase objectsobjects. . TheseThese commandscommands willwill primarilyprimarily bebeusedused byby databasedatabase administratorsadministrators duringduring thethe setupsetup andand removalremoval phasesphasesof of aa databasedatabase projectproject. .

    Specific no tati on f o r defi n in g the Data schemaSpecific no tati on f o r defi n in g the Data schemaExample :Example : C reate TableC reate Table Acc o u n t Acc o u n t (( Acc_N o Acc_N o C har(10)C har(10) ,,

    Bala n ceBala n ce I n teger )I n teger ) DDLDDL compilercompiler generatesgenerates a a setset of of tablestables storedstored inin aa datadata dictionarydictionary DataData Dictionary Dictionary containscontains MetadataMetadata (Data(Data aboutabout Data)Data)

    DatabaseDatabase SchemaSchemaDataData Storage Storage a n da n d Definition Definition La n guageLa n guage

    SpecifiesSpecifies thethe sto

    ragesto

    rage structurestructure an

    dan

    d accessaccess metho

    dsmetho

    ds usedusedI n tegrity I n tegrity Con strai n tsCon strai n ts D o mai nD o mai n Con strai n tsCon strai n ts Refere n tialRefere n tial I n tegrity I n tegrity Asserti on Asserti on

    Auth o rizati on Auth o rizati on

  • 8/7/2019 dbms 2222222

    40/41

    Data Manipulation LanguageData Manipulation Language : :-- (DML)(DML)

    La n guageLa n guage f o rf o r accessi n gaccessi n g a n da n d ma n ipulati n gma n ipulati n g thethe datadatao rga n izedo rga n ized by by thethe appr o priateappr o priate datadata m o delm o del

    DML also known as query languageDML also known as query languageData Manipulation is:Data Manipulation is:

    retrievalretrieval of information from the databaseof information from the database

    insertioninsertion of new information into the databaseof new information into the databasedeletiondeletion of information in the databaseof information in the databasemodificationmodification of information in the databaseof information in the database

    Tw o C lasses o f La n guages :Tw o C lasses o f La n guages :ProceduralProcedural : :

    What Data is Required? What Data is Required? H o w t o get th o se Data?H o w t o get th o se Data?

    DeclarativeDeclarative (Nonprocedural):(Nonprocedural): What Data is Required? What Data is Required? With o ut specifyi n g H o w t o get th o se Data? With o ut specifyi n g H o w t o get th o se Data?

    SQL is the m o st widely used Query La n guage.SQL is the m o st widely used Query La n guage.

  • 8/7/2019 dbms 2222222

    41/41