Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 25

Databases

Why have a database?


Learning Objectives
 Show understanding of the limitations of a file-based approach for
data storage and retrieval
 Describe the features of a relational database
 Explain the advantages of a relational database
 Use ERD diagrams
 Explain normal forms
 Show understanding of DBMS
 Show understanding of DDL and DML
 Write SQL scripts to query or modify data
Database Management System (DBMS)
 Collection of interrelated data
 Set of programs to access the data
 DBMS contains information about a particular enterprise
 DBMS provides an environment that is both convenient and efficient to use.
 Database Applications:
 Banking: all transactions
 Airlines: reservations, schedules
 Universities: registration, grades
 Sales: customers, products, purchases
 Manufacturing: production, inventory, orders, supply chain
 Human resources: employee records, salaries, tax deductions
 Databases touch all aspects of our lives
Purpose of Database System
 In the early days, database applications were built on top of file
systems
 Drawbacks of using file systems to store data:
 Data redundancy and inconsistency
 Multiple file formats, duplication of information in different files
 Difficulty in accessing data
 Need to write a new program to carry out each new task
 Data isolation — multiple files and formats
 Integrity problems
 Integrity constraints (e.g. account balance > 0) become part of program
code
 Hard to add new constraints or change existing ones
Purpose of Database Systems (Cont.)
 Drawbacks of using file systems (cont.)
 Atomicity of updates
 Failures may leave database in an inconsistent state with partial updates carried
out
 E.g. transfer of funds from one account to another should either complete or not
happen at all
 Concurrent access by multiple users
 Concurrent accessed needed for performance
 Uncontrolled concurrent accesses can lead to inconsistencies
 E.g. two people reading a balance and updating it at the same time
 Security problems
 Database systems offer solutions to all the above problems
Flat file vs relational
Storing data in a text file
Storing data in one file or table – flat file

What are the issues?


Definitions
Data privacy

Data Redundancy

Data integrity

Write these in your book

Write three issues with a file storage system – as we have discussed


Databases
 Database
• Collection of related data that is stored in a central location or in
multiple locations
 Data hierarchy: Structure and organization of data involving
fields, records, and files
 Database management system (DBMS)
• Software for creating, storing, maintaining, and accessing database
files
• Makes using databases more efficient
Exhibit 3.2 Interaction Between the User, DBMS and Database

Copyright ©2016 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. MIS5 | CH3 10
Methods for Accessing Files
 Sequential access file structure
• Records are organized and processed in numerical or sequential
order
• Organized based on a primary key
 Social Security numbers or account numbers
• Used for backup and archive files as they rarely need updating
Types of Data in a Database
 Internal
• Collected from within an organization
• Stored in the organization’s internal databases
 External
• Comes from a variety of resources
• Stored in a data warehouse
Methods for Accessing Files
 Random access file structure
• Records can be accessed in any order irrespective of the physical
locations in storage media
• Fast and very effective when a small number of records need to be
processed daily or weekly
• Records are stored on magnetic tapes
Methods for Accessing Files
 Indexed sequential access method (ISAM)
• Records are accessed sequentially or randomly depending on the
number being accessed
 Random access is used for a small number
 Sequential access is used for a large number
• Uses an index structure and has two parts
 Indexed value
 Pointer to the disk location of the record matching the indexed value
Logical Database Design
 Physical view
• Involves how data is stored on and retrieved from storage media
 Hard disks, magnetic tapes, or CDs
 Logical view
• Involves how information appears to users and how it can be
organized and retrieved
• Includes more than one logical view of data, depending on the user
Logical Database Design
 Data model
 Determines how data is created, represented, organized, and
maintained
 Contains
 Data structure
 Operations
 Integrity rules
 Hierarchical model
 Relationships between records form a treelike structure
Exhibit 3.3 A Hierarchical Model

Copyright ©2016 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. MIS5 | CH3 17
Logical Database Design
 Network model
• Similar to the hierarchical model but records are organized differently
• Includes multiple parent and child records
Exhibit 3.4 A Network Model

Copyright ©2016 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. MIS5 | CH3 19
Relational Model
 Uses a two-dimensional table of rows and columns of data
• Rows are records
• Columns are fields
 Data dictionary: Stores definitions
• Data types for fields, default values, and validation rules for data in
each field
Relational Model
 Primary key
• Uniquely identifies every record in a relational database
 Foreign key
• Field in a relational table that matches the primary key column of
another table
• Used to cross-reference tables
Creating a relational database
Band
Band members
Access
Understanding relational tables & keys
MemberID MemberGivenName MemberFamilyName BandName

005 Xiangfei Jha ComputerKidz

009 Mahesh Ravuru ITWizz

BandName AgentID
ComputerKidz 01
ITWhizz 07
What do these terms mean?
1. Relation – A special/specific type of table used in relational databases
2. Attribute – A  field name e.g. BandName, Name, Surname, Age
3. Tuple – A row or record in a database, so one entity with all it's
attributes
4. Atomic values (in a database table) - A single value to represent an
attribute or none
5. Candidate key – A suitable candidate as a primary key (Unique)
6. Primary key -  A unique attribute field e.g. Member ID
Cont…
1. Foreign key – A key used to link back to the primary table
2. Secondary key -  a second suitable primary key that wasn't chosen 
3. Referential integrity – links two tables so that records cannot be
entered in a table where a foreign key is that do not exist in the table
with the primary key linked to it.

You might also like