Introduction To Database System
Introduction To Database System
Data
Data can be facts related to any object inconsideration. For example your name, age, height,
weight, etc are related to you. A picture, image, file, PDF etc can also be considered data.
Database
A database is a systematic collection of data that is organized so that it can easily be accessed,
managed, and updated.
DBMS
A database-management system (DBMS) is a collection of interrelated data and a set of
programs to access those data.
Goals of a database
1. The primary goal of a DBMS is to provide a way to store and retrieve database
information that is both convenient and efficient.
2. The database system must ensure the safety of the information stored, despite system
crashes or attempts at unauthorized access.
3. If data are to be shared among several users, the system must avoid possible anomalous
results.
Database System Applications
Banking: For customer information, accounts, and loans, and banking transactions.
Airlines: For reservations and schedule information.
Universities: For student information, course registrations, and grades
Credit card transactions: For purchases on credit cards and generation of monthly statements.
Telecommunication: For keeping records of calls made, generating monthly bills, maintaining
balances on prepaid calling cards, and storing information about the communication networks.
Finance: For storing information about holdings, sales, and purchases of financial instruments
such as stocks and bonds.
Sales: For customer, product, and purchase information.
Manufacturing: For management of supply chain and for tracking production of items in
factories, inventories of items in warehouses/stores, and orders for items.
Human resources: For information about employees, salaries, payroll taxes and benefits, and
for generation of paychecks.
View of Data
A database system is a collection of interrelated files and a set of programs that allow users to
access and modify these files. A major purpose of a database system is to provide users with an
abstract view of the data. That is, the system hides certain details of how the data are stored and
maintained.
1. Physical level. The lowest level of abstraction describes how the data are actually stored.
The physical level describes complex low-level data structures in detail.
The physical schema describes the database design at the physical level, while the logical
schema describes the database design at the logical level. A database may also have several
schemas at the view level, sometimes called sub schemas that describe different views of the
database.
Of these, the logical schema is by far the most important, in terms of its effect on application
programs, since programmers construct applications by using the logical schema. The physical
schema is hidden beneath the logical schema, and can usually be changed easily without
affecting application programs. Application programs are said to exhibit physical data
independence if they do not depend on the physical schema, and thus need not be rewritten if
the physical schema changes.
Data Models
Underlying the structure of a database is the data model: a collection of conceptual tools for
describing data, data relationships, data semantics, and consistency constraints.
A data model is a collection of tools for describing
✓ Data
✓ Data relationships
✓ Data semantics
✓ Data constraints
List of different types of Data Model
1. Relational model
2. Entity-Relationship data model (mainly for database design)
3. Object-based data models (Object-oriented and Object-relational)
Database Languages
A database system provides a data definition language to specify the database schema and a
data manipulation language to express database queries and updates. In practice, the data
definition and data manipulation languages are not two separate languages; instead they simply
form parts of a single database language, such as the widely used SQL language.
Data-Definition Language
We specify a database schema by a set of definitions expressed by a special language called a
data-definition language (DDL). For instance, the following statement in the SQL language
defines the account table:
Execution of the above DDL statement creates the account table. In addition, it updates a special
set of tables called the data dictionary or data directory. A data dictionary contains
metadata—that is, data about data. The schema of a table is an example of metadata. A database
system consults the data dictionary before reading or modifying actual data.
We specify the storage structure and access methods used by the database system by a set of
statements in a special type of DDL called a data storage and definition language. These
statements define the implementation details of the database schemas, which are usually hidden
from the users.
The data values stored in the database must satisfy certain consistency constraints.
For example, suppose the balance on an account should not fall below $100. The DDL provides
facilities to specify such constraints. The database systems check these constraints every time the
database is updated.
Data-Manipulation Language
Data manipulation is
• The retrieval of information stored in the database
• The insertion of new information into the database
• The deletion of information from the database
• The modification of information stored in the database
A data-manipulation language (DML) is a language that enables users to access or manipulate
data as organized by the appropriate data model. It requires a user to specify what data are
needed without specifying how to get those data.
However, since a user does not have to specify how to get the data, the database system has to
figure out an efficient means of accessing data. The DML component of the SQL language is
nonprocedural.
This query in the SQL language finds the name of the customer whose customer-id is 192-83-
7465:
select customer.customer-name
from customer
where customer.customer-id = 192-83-7465
The query specifies that those rows from the table customer where the customer-id is 192-83-
7465 must be retrieved, and the customer-name attribute of these rows must be displayed. If the
query were run on the table in Figure 1.3, the name Johnson would be displayed.
Queries may involve information from more than one table. For instance, the following query
finds the balance of all accounts owned by the customer with customerid 192-83-7465.
select account.balance
from depositor, account
where depositor.customer-id = 192-83-7465 and
depositor.account-number = account.account-number
Transaction Management
Transaction Management Often, several operations on the database form a single logical unit of work.
An example is a funds transfer, in which one account (say A) is debited and another account (say B) is
credited. Clearly, it is essential that either both the credit and debit occur, or that neither occur. That is,
the funds transfer must happen in its entirety or not at all. This all-or-none requirement is called
atomicity. In addition, it is essential that the execution of the funds transfer preserve the consistency of
the database. That is, the value of the sum A + B must be preserved. This correctness requirement is
Application Architectures
Most users of a database system today are not present at the site of the database system, but
connect to it through a network. We can therefore differentiate between client machines, on
which remote database users work, and server machines, on which the database system runs.
Database applications are usually partitioned into two or three parts. In a two-tier architecture,
the application is partitioned into a component that resides at the client machine, which invokes
database system functionality at the server machine through query language statements.
Application program interface standards like ODBC and JDBC are used for interaction between
the client and the server. In contrast, in a three-tier architecture, the client machine acts as
merely a front end and does not contain any direct database calls. Instead, the client end
communicates with an application server, usually through a forms interface. The application
server in turn communicates with a database system to access data. The business logic of the
application, which says what actions to carry out under what conditions, is embedded in the
Database Administrator
One of the main reasons for using DBMSs is to have central control of both the data and the
programs that access those data. A person who has such central control over the system is called
a database administrator (DBA). The functions of a DBA include:
• Schema definition. The DBA creates the original database schema by executing a set of data
definition statements in the DDL.
• Storage structure and access-method definition.
• Schema and physical-organization modification. The DBA carries out changes to the schema
and physical organization to reflect the changing needs of the organization, or to alter the
physical organization to improve performance.
• Granting of authorization for data access. By granting different types of authorization, the
database administrator can regulate which parts of the database various users can access. The
authorization information is kept in a special system structure that the database system consults
whenever someone attempts to access the data in the system.
• Routine maintenance. Examples of the database administrator’s routine maintenance activities
are: Periodically backing up the database, either onto tapes or onto remote servers, to prevent
loss of data in case of disasters such as flooding. Ensuring that enough free disk space is
available for normal operations, and upgrading disk space as required.
Monitoring jobs running on the database and ensuring that performances not degraded by very
expensive tasks submitted by some users