Transcript PPT

CSCI-235
Micro-Computers in Science
Databases
• Database Concepts
Data is any unorganized text, graphics, sounds, or
videos
A database is a collection of data that is
multidimensional in the sense that internal links
between its entries make the information accessible
from a variety of perspectives
• The Hierarchy of Data
Field – a group of one or more characters that has a
specific meaning
• The smallest meaningful unit of data
• Describes one characteristic of person, place, or thing
Record – the set of fields containing data about a
person, place, or thing
File – a collection of related records
• A file versus a database organization
• Files System Approach
Traditionally, information systems were developed with
a file processing approach
Resulted in a great deal of data redundancy, the
repetition of the same data values
• Increased the risk of inaccurate data
• Increased the amount of storage space needed
• 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
• Atomicity of updates
– Failures may leave database in an inconsistent state with
partial updates carried out
– Example: Transfer of funds from one account to another
should either complete or not happen at all
• Concurrent access by multiple users
– Uncontrolled concurrent accesses can lead to
inconsistencies
– Example: Two people reading a balance and updating it
at the same time
• Example: ATM Bank Server
Service a set of requests
Do so without corrupting database
Don’t hand out too much money
• Database Management System (DBMS)
DBMS contains information about a particular enterprise
• Collection of interrelated data
• Set of programs to access the data
• 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
Human resources: employee records, salaries
Databases touch all aspects of our lives
DBMS allows you to create a database and enter,
modify, and retrieve data as needed
Available at all levels
• Sophisticated systems for a mainframe environment
• Inexpensive, easy-to-use personal computer systems
DBMS Features
•
•
•
•
•
Data maintenance
Data retrieval
Concurrency control
Security
Backup and recovery
• Database Models
Define the way a database organizes data
Four main models
•
•
•
•
Hierarchical
Network
Relational
Object-oriented
• Relational Database
Each entity is stored in a separate table
• Columns represent fields
• Rows represent records
Tables are linked by a relationship between primary
and foreign keys
• Primary Key
A field that uniquely identifies a record
• SalesID can be a primary key for the SalesPerson table
• Once a SalesID appears in the table, no other salesperson
can have that ID
• Foreign Key
A field in one table that is a primary key in another table
• SalesID can be used in the Customer table to identify the
salesperson who serves that customer
• The same SalesID can appear in many customer records (a
salesperson can serve many customers)
• Relational Database
Consists of multiple relations
Information about an enterprise is broken up into parts,
with each relation storing one part of the information
account : stores information about accounts
depositor : stores information about which customer
owns which account
customer : stores information about customers
Storing all information as a single relation results in
repetition of information (e.g., two customers own an
account)
• customer relation
• account relation
• depositor relation
• Integrity Constraints
Define acceptable values for a field
• For example, the value of a month cannot be greater than 12
Primary keys cannot be duplicated
Foreign keys cannot be used unless they exist as a
primary key
• A SalesID that is used in the customer table must exist as a
primary key in the salesperson table