Uploaded on


  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads


Total Views
On Slideshare
From Embeds
Number of Embeds



Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

    No notes for slide


  • 1. DatabasesCutajar & Cutajar
  • 2. Conventional File Approach Each section keeps a separate file for storing information  Example: Attendance and Results filesSTUDENT ATTENDANCE INFORMATIONSurname Name ID Address Father Class ABSENTZammit John 217787M 7 Main Street, Zebbug Charles IT7B 23Cutajar Mary 323187G 9 St. Martin Street, Zejtun George IT4C 1Piscopo Natalie 787887M 9, B. Zammit Street, Attard Peter II2F 78 Duplication of dataSTUDENT RESULTS INFORMATIONSurname Name ID Address Class Subject MarkZammit John 217787M 7 Main Street, Zebbug IT7B English 45Cutajar Mary 323187G 9 St. Martin Street, Zejtun IT4C Maths 90Piscopo Natalie 787887M 9, B. Zammit Street, Attard II2F Korean 12 Databases 2
  • 3. Problems in Conventional File Systems The computer-based subsystems, being self-contained, do not represent the way in which organizations really work Systems communicate with each other outside the computer Possibly data inconsistencies Data duplication Data non-shareable Overall view of company to help decision-making process is almost next to impossible because of the large amount of work involved. Information from different departments has to be collated before appropriate statistics could be obtained - much duplication of data is likely, creating unnecessary maintenance, risk of inconsistencies and wastage of storage space. Databases 3
  • 4. Example Consider a customer order ORDER Customer order Invoice  PROCESSING  (input) (output) SYSTEM (debtor’s Customer control) SALES ACCOUNTING (debtor)   Statements & SYSTEM data confirmation of payments Required stock PURCHASING   Stock order (lacking) SYSTEM Databases 4
  • 5. Integrated File Systems To overcome some of the problems with conventional file systems, integrated file systems are employed. Here, the data is pooled into a set of interlocking and interdependent files, which are accessible by a number of different users (and applications). E.g.: User File A 1 Stock file E.g.: User Process File B 2 Order file User File C 3 … … Databases 5
  • 6. Problems with integrated file systems. When a transaction enters the system, ALL the appropriate files are updated. Most integrated file systems in use are usually tailor- made to meet the requirements of particular organizations. Data duplication problem still remains The task of maintaining the data is shared between the programs that access and maintain the data and therefore lacks proper central control. Programs are still dependant on the nature of the data stored and vice-versa. Databases 6
  • 7. DataBase Management System Databases represent a radically different approach to solving the problems discussed.  Definition: A DATABASE is a single organized collection of structured data stored with a minimum of duplication of data items so as to provide a consistent and controlled pool of data. This data is common to all users of the system, but is independent of the programs that use it.  (Alternative definition: A DATABASE is collection of non- redundant data shareable between different application systems) Databases 7
  • 8. DBMS It is essentially a computerized record-keeping system. D USER 1 B PROCESS USER 2 DATABASE M S USER 3 Databases 8
  • 9. Database Access  Note that, the DBMS is the only medium through which any user may access the data in the database. USER 1 DBMS USER 4 USER 5 USER 2 DataBase USER 3Here it is assumed that the data is contained in a single database. In practice there is often reason for thedata to be split across several distinct databases. Databases 9
  • 10. Computer System Database management systems are available on machines ranging from small microcomputers to the largest mainframes. The facilities provided are to some extent determined by the size and power of the underlying machine.  On large machines one would usually find a multi-user system.  On small microcomputers it is more usual to have a single user database system. Single-User System Multi-User System Databases 10
  • 11. Hardware Requirements With regards to hardware requirements, databases demand large secondary storage facilities, and other demands depending on the circumstances.  Direct access storage e.g. disc packs, and so on.  On-line storage i.e. computer can access a given record without human intervention In a multi-user system, users canaccess the database at the same time For distributed databases, a fast,reliable communications networkwould be a requirement. Distributed System Databases 11
  • 12. Database Environment In a Database Environment there are three classes of users: Application Programmer Responsible for writing programs that use the database End User May access database via an application program Database Administrator (DBA) Has central responsibility of the system. Databases 12
  • 13. Application Programmer Responsible for writing programs that use the database (by issuing appropriate requests to the DBMS) Batch applications – on-line applications Function of programs is to support an end user Databases 13
  • 14. End User May access database via an application program or use the interface provided as an integral part of the system by which the user is able to issue high level commands to the DBMS. Typical functions include:  Data Entry  Issue of Reports  Queries Databases 14
  • 15. Database Administrator (DBA) The DBA has central responsibility of the system.  Co-ordinates database design  Loads the database  Controls access to the database (ensures privacy and security)  Establishes backup and recovery procedures  Controls changes to the database  Selects and maintains database management software  Meets the users to resolve problems and determine changing requirements Databases 15
  • 16. Advantages of Databases vs Traditional Methods Compactness : no need for voluminous paper files Speed : the machine can retrieve and change data much faster than any human Less drudgery : much of the sheer tedium of maintaining files by hand is eliminated Currency : accurate up-to-date information is available on demand at any time. Faster and cheaper development of new applications Databases 16
  • 17. In case of a multi-user environment The database system provides the enterprise with centralized control of its data Redundancy can be reduced (more usually controlled rather than totally eliminated Inconsistency can be avoided Data can be shared Standards can be enforced: to enable data interchange; standards may include corporate, installation, industrial, national, international Security restrictions can be applied: ensuring access to database through proper channels; provision of security checks on access Integrity can be maintained: ensuring that the data in the database is accurate Conflicting requirements can be balanced: provide overall service that is ‘best for the enterprise’ Provision of data independence i.e. if application programs are revised, these changes do not effect the database itself and vice-versa. Databases 17
  • 18. Disadvantages of databases vs traditional methods High initial investment in hardware, software and training Generality that a DBMS provides for defining and processing data Overhead for providing security, concurrency control, recovery, and integrity functions (additional problems may arise if the database designers and DBA do not properly design the database or if the database systems applications are not implemented properly) Databases 18
  • 19. The Database Management SystemThe database management system (DBMS) is a complex software system (system software), which constructs, expands and maintains the database.Main objective of DBMS The DBMS handles all requests from the users for access to the database hence shielding users from hardware level details. Databases 19
  • 20. Functions of a DBMS Allocates storage to data Maintains indices so that any required data can be retrieved, allowing for separate items of data in the base can be cross-referenced Maintains data in the database by providing facilities for adding new records, deleting records, amending records and adding new sets of records (data files) Provides an interface with user programs: Programmer need not be familiar with the structure of the database, and write programs in different programming languages File processing facilities: Process a complete file (serial/sequential), process required records (selective sequential/random) and retrieve individual records Provides security of data: Protects data against unauthorized access, corruption and providing recovery and restart facilities after a hardware or software failure Keeps statistics of the use made of the data, allowing redundant data to be removed and Frequently used data to be kept in the most accessible form Databases 20
  • 21. Data Modeling In designing a database for an enterprise, initially one has to identify and state what data needs to be stored – the data requirements. Example: Stock control application-  Each stock item has a stock number, a description, price, quantity in stock, reorder level and supplier  Each item has only one supplier  From this statement of data requirements a conceptual data model is produced. OPERATIONAL DATA = ENTITIES + RELATIONSHIPS E.g. suppliers E.g. suppliers supplies a certain kind of part – hence link between supplier and part entities Databases 21
  • 22. The Conceptual Data Model A conceptual data model describes how the data elements in the system are to be grouped. Three terms are used in building a picture of the data requirements.  An entity is a thing of interest to an organization about which data is to be stored. - Example: stock, supplier,   An attribute is a property or characteristic of an entity. - Example: stock item description  A relationship is a link or association between entities.- Example: link between stock items and suppliers: - one supplier may supply many stock items This conceptual/logical model is created without any regard to what type of database system will eventually be used to implement it. Example: the entity stock and its attributes are expressed as follows: STOCK(part_number, description, price, quantity, reorder level, supplier) Databases 22
  • 23. Types of Relationships Each relationship has a name (e.g. supplies) and a degree, which may be any of:  one-to-one  one-to-many (or many-to-one)  many-to-many Example :- the relationship between supplier and stock:  Name : supplies (as indicated)  Degree: one-to-many (a supplier supplies many stock items) Databases 23
  • 24. Other Examples E.g. 1: One-to-one: a specialist is assigned to a single ward(Given that a specialist has one ward of patients under his care) E.g. 2: One-to-many: a hospital ward occupied by many patients (but a patient is assigned to only one ward). E.g. 3: Many-to-many: a student may study several courses, each course has many students enrolled on it. Exercise: Identify the relationship between these entities:  stock item and supplier  CD and song  Borrower and book Databases 24
  • 25. Entity-Relationship Diagrams (E-R Diagrams) An entity-relationship diagram is a diagrammatic way of SPECIALIST WARD representing the relationships between the entities in a database. To show the is occupied relationship between two by WARD PATIENTS entities, both the degree and the name of the relationship need to be specified. An E-R diagram illustrates the studies entities and their relationships STUDENT COURSE for a specific system. Databases 25
  • 26. Example 1 The data requirements for a hospital in-patient system are defined as follows:  A hospital is organized into a number of wards. Each ward has a ward number and a name recorded, along with a number of beds in that ward. Each ward is staffed by nurses. Nurses have their staff number and name recorded, and are assigned to a single ward.  Each patient in the hospital has a patient identification number, and their name, address and date of birth are recorded. Each patient is under the care of a single consultant and is assigned to a single ward. Each consultant is responsible for a number of patients. Consultants have their staff number, name and specialisation recorded. (i) State four entities for the hospital in-patient system and suggest an identifier for each of these entities. (ii) Draw an entity-relationship diagram to show the relationship between the entities. Databases 26
  • 27. Solution 1ENTITY NAMEWard Ward NumberNurse Staff NumberPatient Patient Identification NumberConsultant Staff Number staffed by holds visitsNURSE WARD PATIENT CONSULTANT Databases 27
  • 28. Example 2 In a mail order system, a customer may place anorder for several items. Over a period of time, the samecustomer may place several orders. Drawing an E-R CUSTOMER ORDER diagram to All the represent this ORDER ITEM relationship pairs situation: CUSTOMER ITEM sends receives CUSTOMER is for ORDER ITEM Databases 28