SlideShare ist ein Scribd-Unternehmen logo
1 von 28
Downloaden Sie, um offline zu lesen
Databases

Cutajar & Cutajar
Conventional File Approach

 Each section keeps a separate file for storing information
       Example: Attendance and Results files

STUDENT ATTENDANCE INFORMATION
Surname   Name      ID        Address                       Father       Class   ABSENT
Zammit    John      217787M   7 Main Street, Zebbug         Charles      IT7B    23
Cutajar   Mary      323187G   9 St. Martin Street, Zejtun   George       IT4C    1
Piscopo   Natalie   787887M   9, B. Zammit Street, Attard   Peter        II2F    78

                                                 Duplication of data

STUDENT RESULTS INFORMATION
Surname   Name      ID        Address                       Class     Subject    Mark
Zammit    John      217787M   7 Main Street, Zebbug         IT7B      English    45
Cutajar   Mary      323187G   9 St. Martin Street, Zejtun   IT4C      Maths      90
Piscopo   Natalie   787887M   9, B. Zammit Street, Attard   II2F      Korean     12

                                     Databases                                            2
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
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
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
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
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
DBMS

 It is essentially a computerized record-keeping
  system.

                                    D
             USER 1
                                    B
                        PROCESS
            USER 2                          DATABASE
                                    M


                                    S
           USER 3




                        Databases                      8
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 3


Here it is assumed that the data is contained in a single database. In practice there is often reason for the
data to be split across several distinct databases.

                                                 Databases                                                  9
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
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 can
access the database at the same time
 For distributed databases, a fast,
reliable communications network
would be a requirement.                       Distributed System

                             Databases                              11
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
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
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
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
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
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
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
The Database
              Management System
The 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
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
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
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
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
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
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
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
Solution 1
ENTITY         NAME
Ward           Ward Number
Nurse          Staff Number
Patient        Patient Identification Number
Consultant     Staff Number




          staffed by          holds              visits
NURSE                  WARD            PATIENT            CONSULTANT



                                  Databases                            27
Example 2
 In a mail order system, a customer may place an
order for several items. Over a period of time, the same
customer 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

Weitere ähnliche Inhalte

Was ist angesagt? (14)

Apos week 1 4
Apos week 1   4Apos week 1   4
Apos week 1 4
 
Single User v/s Multi User Databases
Single User v/s Multi User DatabasesSingle User v/s Multi User Databases
Single User v/s Multi User Databases
 
Ceis 7
Ceis 7Ceis 7
Ceis 7
 
Chapter1
Chapter1Chapter1
Chapter1
 
Ibm total storage san file system as an infrastructure for multimedia servers...
Ibm total storage san file system as an infrastructure for multimedia servers...Ibm total storage san file system as an infrastructure for multimedia servers...
Ibm total storage san file system as an infrastructure for multimedia servers...
 
Mobile dbms
Mobile dbmsMobile dbms
Mobile dbms
 
Functions of database management systems
Functions of database management systemsFunctions of database management systems
Functions of database management systems
 
Ijetcas14 583
Ijetcas14 583Ijetcas14 583
Ijetcas14 583
 
Lecture 10 distributed database management system
Lecture 10   distributed database management systemLecture 10   distributed database management system
Lecture 10 distributed database management system
 
Characteristic of dabase approach
Characteristic of dabase approachCharacteristic of dabase approach
Characteristic of dabase approach
 
Transparency and concurrency
Transparency and concurrencyTransparency and concurrency
Transparency and concurrency
 
06542014
0654201406542014
06542014
 
Purpose of DBMS and users of DBMS
Purpose of DBMS and users of DBMSPurpose of DBMS and users of DBMS
Purpose of DBMS and users of DBMS
 
Database management system
Database management systemDatabase management system
Database management system
 

Andere mochten auch

Intermediate Operating Systems
Intermediate Operating SystemsIntermediate Operating Systems
Intermediate Operating Systems
John Cutajar
 
Intermediate machine architecture
Intermediate machine architectureIntermediate machine architecture
Intermediate machine architecture
John Cutajar
 
Assembly language 8086 intermediate
Assembly language 8086 intermediateAssembly language 8086 intermediate
Assembly language 8086 intermediate
John Cutajar
 
Binary search
Binary search Binary search
Binary search
Raghu nath
 

Andere mochten auch (20)

Relational
RelationalRelational
Relational
 
SImple SQL
SImple SQLSImple SQL
SImple SQL
 
Topic11 sortingandsearching
Topic11 sortingandsearchingTopic11 sortingandsearching
Topic11 sortingandsearching
 
Relational Database Examples
Relational Database ExamplesRelational Database Examples
Relational Database Examples
 
Intermediate Operating Systems
Intermediate Operating SystemsIntermediate Operating Systems
Intermediate Operating Systems
 
Javanotes
JavanotesJavanotes
Javanotes
 
System design
System designSystem design
System design
 
Intermediate machine architecture
Intermediate machine architectureIntermediate machine architecture
Intermediate machine architecture
 
Module 5 2010
Module 5 2010Module 5 2010
Module 5 2010
 
Oop principles
Oop principlesOop principles
Oop principles
 
Assembly language 8086 intermediate
Assembly language 8086 intermediateAssembly language 8086 intermediate
Assembly language 8086 intermediate
 
Fundamentals of Database Systems Questions and Answers
Fundamentals of Database Systems Questions and AnswersFundamentals of Database Systems Questions and Answers
Fundamentals of Database Systems Questions and Answers
 
Binary search
Binary search Binary search
Binary search
 
Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures
 
System Design
System DesignSystem Design
System Design
 
Fundamentals of Database system
Fundamentals of Database systemFundamentals of Database system
Fundamentals of Database system
 
Algorithms
AlgorithmsAlgorithms
Algorithms
 
Data Structure
Data StructureData Structure
Data Structure
 
Quick sort and binary search PDF
Quick sort and binary search PDFQuick sort and binary search PDF
Quick sort and binary search PDF
 
Assembly language 8086
Assembly language 8086Assembly language 8086
Assembly language 8086
 

Ähnlich wie Databases

Data base management system
Data base management systemData base management system
Data base management system
Suneel Dogra
 
Chap1-Introduction to database systems.ppt
Chap1-Introduction to database systems.pptChap1-Introduction to database systems.ppt
Chap1-Introduction to database systems.ppt
LisaMalar
 
CP 121_2.pptx about time to be implement
CP 121_2.pptx about time to be implementCP 121_2.pptx about time to be implement
CP 121_2.pptx about time to be implement
flyinimohamed
 

Ähnlich wie Databases (20)

DATABASE MANAGEMENT SYSTEM UNIT-I Chapter-1
DATABASE MANAGEMENT SYSTEM UNIT-I Chapter-1DATABASE MANAGEMENT SYSTEM UNIT-I Chapter-1
DATABASE MANAGEMENT SYSTEM UNIT-I Chapter-1
 
Database Management System 1
Database Management System 1Database Management System 1
Database Management System 1
 
Data base management system
Data base management systemData base management system
Data base management system
 
Fundamentals of Database system - Databases and Database Users
Fundamentals of Database system - Databases and Database UsersFundamentals of Database system - Databases and Database Users
Fundamentals of Database system - Databases and Database Users
 
oracle intro
oracle introoracle intro
oracle intro
 
INT 1010 07-2.pdf
INT 1010 07-2.pdfINT 1010 07-2.pdf
INT 1010 07-2.pdf
 
INT 1010 07-5.pdf
INT 1010 07-5.pdfINT 1010 07-5.pdf
INT 1010 07-5.pdf
 
data base unit one on what is databases.pptx
data base unit one on what is databases.pptxdata base unit one on what is databases.pptx
data base unit one on what is databases.pptx
 
Db1 introduction
Db1 introductionDb1 introduction
Db1 introduction
 
Dbms
DbmsDbms
Dbms
 
2ndlec.database
2ndlec.database2ndlec.database
2ndlec.database
 
ppt on database management
ppt on database management ppt on database management
ppt on database management
 
rdbms-notes
rdbms-notesrdbms-notes
rdbms-notes
 
Chap1-Introduction to database systems.ppt
Chap1-Introduction to database systems.pptChap1-Introduction to database systems.ppt
Chap1-Introduction to database systems.ppt
 
Dbms
DbmsDbms
Dbms
 
DBMS
DBMSDBMS
DBMS
 
CP 121_2.pptx about time to be implement
CP 121_2.pptx about time to be implementCP 121_2.pptx about time to be implement
CP 121_2.pptx about time to be implement
 
Database & dbms
Database & dbmsDatabase & dbms
Database & dbms
 
Dbms
DbmsDbms
Dbms
 
Overview of databases
Overview of databasesOverview of databases
Overview of databases
 

Databases

  • 2. Conventional File Approach  Each section keeps a separate file for storing information  Example: Attendance and Results files STUDENT ATTENDANCE INFORMATION Surname Name ID Address Father Class ABSENT Zammit John 217787M 7 Main Street, Zebbug Charles IT7B 23 Cutajar Mary 323187G 9 St. Martin Street, Zejtun George IT4C 1 Piscopo Natalie 787887M 9, B. Zammit Street, Attard Peter II2F 78 Duplication of data STUDENT RESULTS INFORMATION Surname Name ID Address Class Subject Mark Zammit John 217787M 7 Main Street, Zebbug IT7B English 45 Cutajar Mary 323187G 9 St. Martin Street, Zejtun IT4C Maths 90 Piscopo 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 3 Here it is assumed that the data is contained in a single database. In practice there is often reason for the data 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 can access the database at the same time  For distributed databases, a fast, reliable communications network would 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 System The 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 1 ENTITY NAME Ward Ward Number Nurse Staff Number Patient Patient Identification Number Consultant Staff Number staffed by holds visits NURSE WARD PATIENT CONSULTANT Databases 27
  • 28. Example 2  In a mail order system, a customer may place an order for several items. Over a period of time, the same customer 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