Basic Concepts of Databases

advertisement
CST203-2 Database Management Systems
Lecture 2
One Tier Architecture
 Eg:
 In this scenario, a workgroup database is stored in a
shared location on a single machine
 Beneficial when we are dealing with data that is
relevant to a single user
Client / Server architecture
System functionality is distributed between
 Client module
 Server module
3 tier architecture
 To ensure more security and load balancing for a
greater stability
Data models
 A collection of concepts that can be used to describe the
structure of a database
 “An integrated collection of concepts for describing data,
relationships between data, and constraints on the data.

Database Solutions: A Step-by-step approach to building databases
 Include a set of basic operations for specifying retrievals
and updates on db
Categories of Data Models
 High-level or Conceptual Data models
 Low-level or physical data models
 Representational or implementation data models



Relational data model
Network data model
Hierarchical data model
Levels of Abstraction
 Physical level describes how a record (e.g.: customer) is stored.
 Logical level: describes data stored in database, and the
relationships among the data.
type customer = record
name : string;
street : string;
city : integer;
end;
 View level: application programs hide details of data types.
Views can also hide information (e.g., salary) for security
purposes.
Database Schema
 The logical structure of the database
 Eg: the database consists of information about a set of
customers and accounts and the relationship between
them
Database Instance
 The actual content of the database at a particular
point in time
Three Schema Architecture
 The external schema
 Defines one view of data as seen by a specific set of
applications or end users
 The conceptual schema
 Defines data from perspective of system designer
 Independent of end users and data storage mechanism
 The internal schema
 Defines how data is organized, stored and manipulated in the
application itself
 Totally dependent on particular implementation
Data Independence
 Logical Data Independence
 Physical Data Independence
Entity
 Represents a real world object or concept
 Eg: an employee, a project
Attribute
 Represents some property of interest that further
describes an entity
 Eg: employee’s name or salary
Relationship
 Represents an association among 2 or more entities
 Eg: an employee works on a project
 Example of schema in the entity-relationship model
A Sample Relational Database
Data Definition Language (DDL)
 Specification notation for defining the database schema

E.g.
create table account (
account-number char(10),
balance
integer)
 DBMS have a DDL compiler
 Data dictionary contains metadata (i.e., data about data)
 Database schema
 Data storage and definition language


language in which the storage structure and access methods used by the
database system are specified
Usually an extension of the data definition language
Data Manipulation Language (DML)
 Language for accessing and manipulating the data
organized by the appropriate data model

DML also known as query language
 Two classes of languages


Procedural – user specifies what data is required and how to get
those data
Nonprocedural – user specifies what data is required without
specifying how to get those data
 SQL is the most widely used query language
SQL
 SQL: widely used non-procedural language


E.g. find the name of the customer with customer-id 192-83-7465
select customer.customer-name
from customer
where customer.customer-id = ‘192-83-7465’
E.g. find the balances of all accounts held by the customer with customer-id 19283-7465
select account.balance
from depositor, account
where depositor.customer-id = ‘192-83-7465’ and
depositor.account-number = account.account-number
 Application programs generally access databases through one of


Language extensions to allow embedded SQL
Application program interface (e.g. ODBC/JDBC) which allow SQL queries to be
sent to a database
Transaction Management
 A transaction is a collection of operations that performs a
single logical function in a database application
 Transaction-management component ensures that the
database remains in a consistent (correct) state despite
system failures (e.g., power failures and operating system
crashes) and transaction failures.
 Concurrency-control manager controls the interaction
among the concurrent transactions, to ensure the
consistency of the database.
Example:
 Consider a possible interleaving
T1:
T2:
A=A+100,
A=1.06*A,
B=B-100
B=1.06*B
This is OK. But what about this ???????
T1:
T2:
A=A+100,
A=1.06*A, B=1.06*B
B=B-100
Storage Management
 Storage manager is a program module that provides
the interface between the low-level data stored in the
database and the application programs and queries
submitted to the system.
 The storage manager is responsible to the following
tasks:


Interaction with the file manager
Efficient storing, retrieving and updating of data
Download