meljun database dbms lecture

Upload: meljun-cortes-mbampa

Post on 30-May-2018

226 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/14/2019 MELJUN Database Dbms Lecture

    1/56

    DATABASESYSTEMMELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    2/56

    We Are Learning TodayTo recognize what a database is and identifywhere one might be used in and out of school.

    To reconize the meaning ofkey database termssuch as Table, Record, Field, Form, Report andQuery.To understand what querying a database is.Understanding Basic Database concepts

    MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    3/56

    DATA ORGANIZATIONCHARACTER is the basic building block of DATA which

    consist of upper & lower case letter numeric

    digit (0, 1, 2, etc.) or special character (-, +, -).

    CHARACTER are put together to form a FACT.FACT are called Field, Item, Word, or String of Character.FACT a number, a name, or a combination of Character.

    RECORDa collection of related FACTS.Example:1.) Employee Recordit is collection of FACT about one employee.

    2.) It indicates name, address, phone #, pay rate, earning made to

    date & so on.

    MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    4/56

    FILE

    is a collection of related RECORD.Example:1.) A collection of all employee record for one company

    would be an Employee File.

    2.) Inventory Filecollection of all inventory record for

    a particular company or organization.

    DATA ORGANIZATION

    Student ID# : 034456

    Student Name : MELJUN CORTESCourse : BSCS 4

    Birthday : October 2, 1975

    Zodiac Sign : Libra

    Student ID# : 034456Student Name : MELJUN CORTES

    Course : BSCS 4

    Birthday : October 2, 1975

    Zodiac Sign : Libra

    Student ID# : 034456Student Name : MELJUN CORTES

    Course : BSCS 4

    Birthday : October 2, 1975

    Zodiac Sign : Libra

    FILERECORD

    MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    5/56

    DATA ORGANIZATIONHIERARCHY OF DATA :

    CHARACTER are combined to make a Fact.FACT are combined to make Record.RECORD are combined to make File.FILE are combined to make DataBase

    DataBase

    File

    Record

    Fact

    Character

    Note: The Heart of most Organization isDATA.DataBase is a collection of integrated & related master file.Note: A data base is used as the raw material or input data

    for all of the application system perform by the

    organization. MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    6/56

    ATABASE SYSTEM

    MELJUN CORTES

    Number Date Customer Amount

    101 Oct 30, 2009 MELJUN CORTES 12,500

    102 Dec. 12, 2009 PIOLO PASCAUL 78,452

    103 Nov. 15,2009 MARTIN RIVERA 89,500

    104 Jan. 14,2010 SAM MELBY 10,500

    Each ROW is a RECORD.Each COLUMN is a FIELD.COLUMN TITLES are FIELD NAME.The type of DATA stored in a FIELD is a FIELD TYPE.The number of CHARACTER in a FIELD is its FIELD WIDTH.A DATABASE is composed of one or more TABLE.A DATABASE is a FILE which is created in automated DBMS SOFTWARE.

    FIELD NAME

    RECORDRECORDRECORDRECORD

    TABLE

  • 8/14/2019 MELJUN Database Dbms Lecture

    7/56MELJUN CORTES

    EXAMPLE OF DATABASE STRUCTURE:Structure for Database :C:\STLMASTER.dbfNumber of Data Records : 268 recordsDate of last update : 10/26/1996Filename of DATABASE FILE : STLMASTER.dbfField Field Name Field Data Types Field Width Dec Index

    1 AppNumber character 62 AppDate date 83 Name character 204 Address character 305 LoanAmount numeric 12 26 Rebate numeric 7 27 Interest numeric 7 28 Balance numeric 12 29 Penalty numeric 7 2

  • 8/14/2019 MELJUN Database Dbms Lecture

    8/56

    DATA ORGANIZATIONDATA is a raw materials or input to anydata processing system.- is considered as INPUT DATA.- is manipulated to provide OUTPUT DATA.Example: Student Admission Form & Enrollment Form

    Pay Slip of an employee

    INFORMATION when this OUTPUT DATA can be

    used to help people make economic

    decision making.

    DATA PROCESSING is that procedures of transforming

    INPUT DATA into

    desired OUTPUT DATA.MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    9/56

    DATA ORGANIZATIONINFORMATION PROCESSING a special case ofdataprocessing is the

    procedure of transforming data intoinformation whichcan be used to make better decision.

    Data Processing System includes all people, procedures &

    computer device used to produce

    desirable output or meaningful

    information.

    Information Processing System includes all people,procedures, computerdevices used to procedure usefulthat can be used in decision makingMELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    10/56

    DATA ORGANIZATIONOverview of DATA Processing

    Ex. Payroll System

    INPUT PROCESSING OUTPUT

    Example:1.) Pay Rate2.) Hours Worked3.) PayrollDeduction

    Example:

    1.) Classifying

    2.) Sorting

    3.) Calculating

    4.) Storing

    5.) Summarizing

    6.) Reproducing

    Example:1.) Pay Slip2.) PayrollReport

    MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    11/56

  • 8/14/2019 MELJUN Database Dbms Lecture

    12/56

    DATABASESYSTEMMELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    13/56

    DATABASE SYSTEMDatabase ConceptsData vs.Information

    DBMSMELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    14/56

    DatabaseComputerized RecordKeeping SystemCollection of Data used by anorganization to

    1. Record its Operations2. Support Decision Making

    MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    15/56

    DataRaw facts and figuresCan be of typeTextNumber

    Sound, Image, Chart,VideoMELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    16/56

    InformationProcessed Data

    Used for Decision Making

    Data is alsoINFORMATION

    Information createsDATA

    MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    17/56MELJUN CORTES

    EXAMPLE OF DATABASE STRUCTURE:Structure for Database :C:\STLMASTER.dbfNumber of Data Records : 268 recordsDate of last update : 10/26/1996Filename of DATABASE FILE : STLMASTER.dbfField Field Name Field Data Types Field Width Dec Index

    1 AppNumber character 62 AppDate date 83 Name character 204 Address character 305 LoanAmount numeric 12 26 Rebate numeric 7 27 Interest numeric 7 28 Balance numeric 12 29 Penalty numeric 7 2

  • 8/14/2019 MELJUN Database Dbms Lecture

    18/56

    ATABASE SYSTEM

    MELJUN CORTES

    Number Date Customer Amount

    101 Oct 30, 2009 MELJUN CORTES 12,500

    102 Dec. 12, 2009 PIOLO PASCAUL 78,452

    103 Nov. 15,2009 MARTIN RIVERA 89,500

    104 Jan. 14,2010 SAM MELBY 10,500

    Each ROW is a RECORD.Each COLUMN is a FIELD.COLUMN TITLES are FIELD NAME.The type of DATA stored in a FIELD is a FIELD TYPE.The number of CHARACTER in a FIELD is its FIELD WIDTH.A DATABASE is composed of one or more TABLE.A DATABASE is a FILE which is created in automated DBMS SOFTWARE.

    FIELD NAME

    RECORDRECORDRECORDRECORD

    TABLE

  • 8/14/2019 MELJUN Database Dbms Lecture

    19/56

    A DataBase Management System

    (DBMS)often just called Database SoftwarInput Processing Output

    Storing

    Querying

    Sorting

    FORMS REPORTSSourcesDocumentsLike:Enrollment Forms

    PrintedDocumentsLike:Assessment Forms

    MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    20/56

    Database TerminologyTerm MeaningDatabase

    Table

    Record

    Field

    Data Type

    An organised collection (or Store) of data.A collection of related records, such

    as all the pupil records in a class.

    A collection of related fields, suchas a pupils record.An individual data item, such asFirstname or Date of Birth.Type of information in a field such astext, numeric, date and boolean (Yes/No)

    MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    21/56

    The Russian Doll Analogy

    Fields insideof

    A Database

    Tablesinside ofRecordsinside of

    Data insideof

    MELJUN CORTES

    DATABASE SYSTEM

  • 8/14/2019 MELJUN Database Dbms Lecture

    22/56

    ATABASE SYSTEM

    MELJUN CORTES

    Number Date Customer Amount

    101 Oct 30, 2009 MELJUN CORTES 12,500

    102 Dec. 12, 2009 PIOLO PASCAUL 78,452

    103 Nov. 15,2009 MARTIN RIVERA 89,500

    104 Jan. 14,2010 SAM MELBY 10,500

    Each ROW is a RECORD.Each COLUMN is a FIELD.COLUMN TITLES are FIELD NAME.The type of DATA stored in a FIELD is a FIELD TYPE.The number of CHARACTER in a FIELD is its FIELD WIDTH.A DATABASE is composed of one or more TABLE.A DATABASE is a FILE which is created in automated DBMS SOFTWARE.

    FIELD NAME

    RECORDRECORDRECORDRECORD

    TABLE

  • 8/14/2019 MELJUN Database Dbms Lecture

    23/56MELJUN CORTES

    EXAMPLE OF DATABASE STRUCTURE:Structure for Database :C:\STLMASTER.dbfNumber of Data Records : 268 recordsDate of last update : 10/26/1996Filename of DATABASE FILE : STLMASTER.dbfField Field Name Field Data Types Field Width Dec Index

    1 AppNumber character 62 AppDate date 83 Name character 204 Address character 305 LoanAmount numeric 12 26 Rebate numeric 7 27 Interest numeric 7 28 Balance numeric 12 29 Penalty numeric 7 2

  • 8/14/2019 MELJUN Database Dbms Lecture

    24/56

    What is a DBMS?A collection of computer programs that allowstorage, modification, and extraction ofinformation from a database. There are manydifferent types of DBMS ranging from small

    systems that run on personal computers tohuge systems that run on mainframes.

    Examples--

    Computerized library systems, automated

    teller machines, flight reservation systems,

    computerized parts inventory systems.

    MELJUN CORTES

    DATABASE SYSTEM

  • 8/14/2019 MELJUN Database Dbms Lecture

    25/56

    IntroductionTo DBMSConcepts

    MELJUN CORTES

    DATABASE SYSTEM

  • 8/14/2019 MELJUN Database Dbms Lecture

    26/56

    What is a DBMS?A collection of computer programs that allowstorage, modification, and extraction ofinformation from a database. There are manydifferent types of DBMS ranging from small

    systems that run on personal computers tohuge systems that run on mainframes.

    Examples--

    Computerized library systems, automated

    teller machines, flight reservation systems,

    computerized parts inventory systems.

    MELJUN CORTES

    DATABASE SYSTEM

  • 8/14/2019 MELJUN Database Dbms Lecture

    27/56

    Examples of DATABASE(1)Admission SystemExamination SystemLibrary SystemPayroll & PersonnelManagement SystemAccounting SystemHotel Reservation SystemAirline Reservation System

    MELJUN CORTES

    DATABASE SYSTEM

  • 8/14/2019 MELJUN Database Dbms Lecture

    28/56

    Examples of DATABASE(2)Patient Recording SystemInventory SystemSales and Purchase and AccountingSystemEnrollment SystemKnowledge-Based Management SystemEvery Government, Military, Private andother organizations plus Individual canmake use of DB

    DATABASE SYSTEM

    MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    29/56

    Data ManagementManual Filing SystemComputerized Filing SystemDatabase Systems

    DATABASE SYSTEM

    MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    30/56

    Filing SystemEvery Department/Company has its ownData File(s)

    Application to Maintain Data File(s)-- Computerized Data Maintenance System

    DATABASE SYSTEM

    MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    31/56

    Library System - ExampleMembers

    Catalog

    Register

    Members

    Management

    Application

    Catalog

    Management

    Application

    Transaction

    Management

    Application

    Lists of All Members,

    New Members,

    Joins between

    specified Dates. etc

    Lists of All Books,

    New Books,

    Issued Books,

    Lost Books,. etc

    Books Issued Today,

    Books Receipt Today,

    etc

    Files Applications Operations

    MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    32/56

    Database SystemSingle, Central, Large Repository

    Shared ResourceHave Logical Connectionsamong data itemsDBA is responsible of its design,creation and maintenance

    MELJUN CORTES

    Is a PERSON

  • 8/14/2019 MELJUN Database Dbms Lecture

    33/56

    Members

    Management

    Application

    Catalog

    Management

    Application

    Transaction

    Management

    Application

    Lists of All Members,

    New Members,

    Joins between

    specified Dates. etc

    Lists of All Books,

    New Books,

    Issued Books,

    Lost Books,. etc

    Books Issued Today,

    Books Receipt Today,

    etc

    Members

    Catalog

    Register

    DBMS

    DATABASE SYSTEM

    MELJUN CORTES

    Library System - Example

  • 8/14/2019 MELJUN Database Dbms Lecture

    34/56

    DBMSSoftware Package that providesSupport to applications system-- Computerized DATA HandlingUser-interface for on-line queries

    MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    35/56

    Advantages of DBMS (1)Sharing of DataControl of Redundancy-(unnecessary wastage of disk space)

    Data ConsistencyImprovement of Data StandardsImprovement of Data Integrity-(Intra-record, inter-record, referential)Balancing of Conflicts

    Faster Development of New Applications

    DATABASE SYSTEM

    MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    36/56

    Advantages of DBMS (2)Better Security

    PasswordsEncryptionViews and Stored Procedures

    Better Data Accessibility(query language- SQL programming)

    Economy of ScaleTransaction handlingBetter backup and Recovery Procedures

    MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    37/56

    Disadvantages of DBMSHigher Costs of

    DBMSHardwareConversionProgramming

    Slow Processing of SomeApplicationsMore Security RisksMore Difficult Recovery

    MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    38/56

    Kinds of DatabasesRelational: Oracle 9i/8i, SQL-Server 2000/7.0/6.5,

    Teradata, Sybase(SQL Anywhere),

    DB2, Informix

    MS-Access, Foxpro 2.6/2.5,dbase IV/3 +

    Network e.g. IDS Server

    Paradox, FoxBase, Dbase3+, DbaseIV

    DBU, Visual FoxPro, MS-Access Windows 7

    MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    39/56

    Relational DBMS

    TABLE

    TABLE

    TABLETABLE

  • 8/14/2019 MELJUN Database Dbms Lecture

    40/56

    Important RDBMS ObjectsTablesViewsTriggersStored ProceduresFunctionsPrimary KeyForeign Key

    MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    41/56

    Networked DBMS

    MELJUN CORTES

    SQL:

  • 8/14/2019 MELJUN Database Dbms Lecture

    42/56

    SQL:

    It is an acronym for Structured QueryLanguage.It is the language in which, the clientsends the requestto the database for dataEg. Select name, address

    From empWhere city = BUTUAN CITY

    SQL:

    MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    43/56

    PL/SQL:It is an acronym for Programming Language/Structured QueryLanguage

    Apart from writing the SQL you also have the programminglanguage constructs like

    If then else (checking conditions)

    Looping (Executing the set of statements more that once) Exception and error handling (Taking care of run time errors)

    MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    44/56

    Database DesignDatabase design

    is the process of producing a detailed

    data model of a database. This logical data model contains all theneeded logical and physical design choices and physical storageparameters needed to generate a design in a Data DefinitionLanguage, which can then be used to create a database. A fullyattributed data model contains detailed attributes for each entity.

    Process: Determine the data to be stored in the database Determine the relationships between the different data elements Superimpose a logical structure upon the data on the basis of

    these relationships.

    MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    45/56

    Database ObjectsA Database Trigger is procedural code that is automatically executed in

    response to certain events on a particular table in a database. Triggerscan restrict access to specific data, perform logging, or audit datamodifications.A Database View is a virtual or logical table composed of the result setof a query. Unlike ordinary tables (base tables) in a relational database,a view is not part of the physical schema: it is a dynamic, virtual tablecomputed or collated from data in the database. Changing the data in atable alters the data shown in the viewIn relational databases, SQL databases, and flat file databases,a Table is a set of data elements (values)that is organized using a model of horizontalrows and vertical columns.

    MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    46/56

    In database packages, the term Cursor refers to a control structureor the successive traversal (and potential processing) of records in aresult set.Transaction Log (also database log or binary log) is a history ofactions executed by a database management system to guaranteeCID properties over crashes or hardware failures. Physically, a log is

    a file of updates done to the database, stored in stable storage.Database Index is a data structure that improves the speed ofoperations in a table. Indexes can be created using one or morecolumns, providing the basis for both rapid random lookups andefficient ordering of

    access to records.Stored Procedure is a subroutine available to applicationsaccessing a relational database system. Stored procedures(sometimes called a sproc or SP) are actually stored in thedatabase.

    Database Objects

    MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    47/56

    NormalizationWhy Normalize?

    Ideally, a relational database table should be designed in such away as to exclude the possibility of update, insertion, and deletionanomalies. The normal forms of relational database theory provideguidelines for deciding whether a particular design will be

    vulnerable to such anomalies. It is possible to correct anunnormalized design so as to make it adhere to the demands ofhe normal forms: this is called normalization.

    A

    tablethat is not sufficiently normalized can suffer from

    logical inconsistencies of various types, and fromanomalies involving data operations causingUpdate, Insert and Delete Anomalies.

    MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    48/56

    TRANSACTION MANAGEMENTWhat is a Database Transaction ?

    A database transaction is a unit of interaction with adatabase management system or similar system that istreated in a coherent and reliable way independent of othertransactions. In general, a database transaction must be

    atomic, meaning that it must be either entirely completedor aborted. Ideally, a database system will guarantee theproperties of Atomicity, Consistency, Isolation andDurability (ACID) for each transaction.

    A Simple Transaction1. Begin the transaction2. Execute several queries3. Commit the transaction

    MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    49/56

    ACIDIncomputer science, ACID (Atomicity, Consistency, Isolation, Durability)is a set of properties that guarantee that database transactions are processed reliably. In thecontext of databases, a single logical operation on the data is called a transaction.

    Atomicity - Atomicity refers to the ability of the DBMS to guarantee that either all of the tasksof a transaction are performed or none of them are.Consistency - Consistency refers to the database being in a legal state when the transactionbegins and when it ends. This means that a transaction cannot break the rules, or integrityconstraints, of the database.Isolation - Isolation refers to the ability of the application to

    make operations in a transaction appear isolated fromall other operationsDurability -Durability ensures that the results of a completedtransaction are permanent and can survive future system andmedia failures; that is, once they are done, they can not be undone.

    MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    50/56

    Kinds of DatabaseConsultants

    DATABASE Designers

    is a personDATABASE Developers

    is a person

    DBA (Data Base Administrator)

    is a person

    DATABASE SYSTEM

    MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    51/56

    DATABASE Designers:These consultants Analyze,design the complete structureof the database.They design Tables, Views,Normalization, ER Diagram,Integrity constraints, etc.

    DATABASE SYSTEM

    MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    52/56

    DATABASE Developers:These consultant write storedprocedures, triggers, functions, etc.Technical terms found in the resumesuch consultants TriggersStored ProceduresPackagesUnix Shell Scripting

    MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    53/56

    DBADMINISTRATOR:These consultants profileincludes installation,configuration, migration,backup, recovery operationsVarious Tasks of the DBA are:

    a) Granting accessb) User creation and deletionc) Performance tuningd) Query optimization

    DATABASE SYSTEM

    MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    54/56

    Related Skills in DATABASESYSTEMata WarehousingDevelopment of a data warehouse includes developmentof systems to extract data from operating systems plusinstallation of a warehouse database system thatprovides managers flexible access to the dataData MiningA class of database applications that look for hiddenpatterns in a group of data that can be used to predictfuture behaviorData ModelingThe analysis of data objects and their relationships toother data objects. Data modeling is often the first stepin database design and object-oriented programming asthe designers first create a conceptual model of howdata items relate to each other. Data modeling involvesa progression from conceptual model to logical model tophysical schema.

    MELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    55/56

    DATABASESYSTEMMELJUN CORTES

  • 8/14/2019 MELJUN Database Dbms Lecture

    56/56