Sunteți pe pagina 1din 36

Introduction To Database

Definition of Database
• Database is an organized collection of related data that is
stored in an efficient and compact manner.
• The word organized mean that data is stored in such away
that the user can use this data easily.
• The word related mean that a database is normally created to
store a data about a particular topic.
• The word efficient means that the user can search the required
data quickly
• The word compact means that the stored data occupies as
little space as possible in computers
Examples of Database
Examples:
Some examples of database are as follows:
1. Phone Directory
A phone directory stores the phone numbers of different
peoples. Any phone number from the phone directory can be
searched easily because all phone numbers are stored in an
organized way.
2. Library:
A library contain thousands of books. A database system
can be used to store the records of books. The database can
be used to search the required books easily.
Examples Of Database
3. College Record
A college has many students in different classes a database
is used to store the records of the students , fee transactions,
examination information and the attendance of the students.
Database Management System
A database management system (DBMS) is a software that is used to create,
maintain and access databases in a convenient manner.
• Characteristics of DBMS:
The most important characteristics of database are
- Efficiency
- Compactness
- Efficiency :
A database management system stores, retrieves and manipulates data in a
database with efficiency. It takes far less time to manipulate data as
compared to file system. It uses the processing power of computer to
increase its efficiency.
Characteristics of DBMS:

- Compactness:
Compactness refers to the way of storing data in a database .
A database management system stores data in less space than file system.
Storage capacity of computer is used properly.
Advantages Of Database Management
System
Some of the advantages are as follow:
• Data Consistency
• Better Data Accessibility
• Consistency Constraints
• Data Atomicity
• Data Security
• Data Sharing
• Compactness
• Report Writing
Data Consistency
• In an ordinary file system one data item has to be stored in
several places. If there is any change in data ,it has to change
in all places. On the other hand ,in Database Management
System ,one data item is usually stored at one place .Thus
whenever a data is retrieved always the current value is used.
Better Data Accessibility
• Data can be retrieved more easily in database system
than in an ordinary file system
• Database system provides special data access language
and technique to store and retrieve data
Example:
• In a school database, it is easy to retrieve data of the
students who got more than 80% marks in last
examination.
• On the other hand ,in an ordinary file system ,a separate
program is needed to get such a information.
Consistency Constraints
• Consistency constraints are the rules that must be followed to
enter data in database. If a data does not fulfill any of these
constraints ,It cannot be entered in a database.
• In a database management system consistency constraints must
be applied ,while in an ordinary file system ,It is difficult to
enforce such conditions .
Data Atomicity
• One complete operation carried out on a database is called a transaction.
• The Atomicity means that in a database management system, either one
transaction takes place as a whole or it does not take place at all. this
property ensure that the database will always have correct and consistent
data .
Example:
• In an ordinary file system, the names of students who have paid their fee is
maintained in one file and the names of students who have not paid their
fee is maintained in another file . If a student has paid his fee, his name is
entered in the file that contains the names of students who have paid their
fee. it is possible that , for some reasons ,the name of the student is not
removed from the file that contains the names of the students who have not
paid their fee. thus the name of the student will appear in both files and the
data will become inconsistent.
• The database management system does not allow such a situation to
happen.
Security
• Data Security is the protection of the database from unauthorized access
.the Database Management System provides several procedures to maintain
data security. the security is maintained by allowing access to the database
through use of passwords.
• Secrecy: Users should not be able to see things they are not supposed to.
– E.g., A student can’t see other students’ grades.
• Integrity: Users should not be able to modify things they are not
supposed to.
– E.g., Only instructors can assign grades.
• Availability: Users should be able to see and modify things they are
allowed to.
Data Sharing
• A Database is usually created for one application .But this
Database can also be easily used for new applications that
need the same data or a portion of the data.
Compactness
• The Database management system maintains data in a compact
and efficient manner.
• It needs far less storage space than the ordinary file system

Report Writing
• Presentation of processed data obtained from a database is
called report.
• The output report can be prepared very easily and quickly in
the required format in a database management system.
Disadvantages of Database
System
A computerized database management system has several
advantages over the traditional file system of maintaining
records.
However ,it has some limitations and disadvantages too.
Some of disadvantages are :
• High cost of DBMS
• High conversion cost
• Trained people
High Cost of DBMS
• A complete database management system consist
of sophisticated software.
• It also has hardware requirements .
• The whole system can cost a large amount .
• Only large business concerns can benefit from it.
High Conversion Cost
• When an organization shifts its records to
database management system , data has to be
converted from files into the database system .
• Because of the different formats used by different
systems this may be time consuming process .
• In addition to this , the structure and data may
also have to be modified according to the
requirements of the database management system.
Trained People
• Trained people are required to manage the
database management system . Theses people are
called database administrators. This also increases
the system cost.
Categories of Database
The range of database can be divided into four categories.
• Personal databases
• Workgroup databases
• Department databases
• Enterprise databases
Personal Databases
• Personal databases are designed to support one user .
• Personal databases have long resided on personal
computers , including laptops.
• The size of database is usually in Megabytes.
Workgroup Databases
• A workgroup is relatively small team of
people who collaborate on the same project
or application or on a group of similar
projects or applications.
• A workgroup typically comprises fewer
than twenty five persons.
• The size of databases varies from
Megabytes to Gigabytes.
Department Databases
• A department is a functional unit within an organization.
• Typically examples of departments are marketing,
manufacturing and accounting.
• A department is generally larger than workgroup( typically
between 25 and 100 persons)
• Department databases are designed to support various
functions and activities of a department.
• The size of databases is usually in Gigabytes.
Enterprise Databases
• An enterprises database is one whose scope is the entire
organization or enterprise.
• Such databases are intended to support organization wide
operations and decision making.
• Typical number of users are more than 100.
• The size of database varies from Gigabytes to Terabytes.
Relational Database
• A database in which data is stored in relations is called
relational database.
• Relation is another term used for table.
• A table in a database has a unique name that identify its
contents.
Characteristics of Relational Databases
Two important characteristics of relational databases are
as follows
1. All data in database is stored in tables.
2. All data from a relational database is retrieved as tables.
Database Objects:
The database objects used to store data is as
follows:
• Tables
The database object used to retrieve data through
Queries.
Tables
• Table is the central concept in relational databases.
All data in a relational database is stored in tables.
Table is known as relation
• Following is an example of table :

Registration No Name Class


08-arid-255 Farwa MSc

08-arid-300 Talal BSc

08-arid-296 Sara MSc


Tables
• In relational database, a relation consists of rows and
column.
• Rows are also called records
• In the above figure , the information of each student is
stored in a separate row. each row is subdivided into
fields or attributes
Queries
• Queries are used to retrieve the required data from the
database
• Data is retrieved according to the criteria given by the
user
• The query is written in database access language.
• It retrieve data from the database and displays it in the
form of table
• The most commonly used query language is SQL
Queries
• If user executes a query to retrieve the records of the students
who are in MSc.
• The query will display the following table as result.

Registration No Name Class


08-arid-255 Faria MSc
08-arid-296 Sara MSc
Forms and Reports
• The Forms and Reports are important features of a
database system.
Forms:
• The graphical interface used to interact with database is
called form
• Forms are used to enter data in the database
• A form consist of textboxes ,labels and buttons that are
used by the users for entering data easily
• The user can also retrieve ,change and update data by
using forms.
Forms and Reports
Reports:
• Reports are the outputs of database application
• The user can generate different types of reports by
manipulating the database .
• Reports are very important in making key decisions
• The information on the reports is arranged in different
ways.
• A report may also contain graphs, charts and tables etc.
Primary Key
• An attribute which can uniquely identify each record of
a relation (table).
• Primary can be one of the following
1. Simple primary key
2. Composite primary key
• If primary key consists of single attribute, it is called
simple primary key
• If primary key consists of two or more fields ,it is called
composite primary key
Foreign Key
• A Foreign key is a field or combination of fields in a table
that reference a primary key in another table.
• The key connects to another table when relationship is
being established between two tables .
• A table may contain many foreign keys
Example of a Relational Database

Relation Name
Attribute
Primary Key (PK)
Sale
SalesNO Rate City Dept#
10 10 Dallas A211
12 15 Denver F654
48 8 WashDC A211

Tuple (record)
Example of a Relational Database

Customer
CustID Name Balance City SaleNo
132 Black 2000.00 Dallas 10
135 Tom 129.89 Denver 12
198 Tom (132.90) Dallas 10
SalesNO is PK in Sales table
Sale
SalesNO Rate City Dept#
10 10 Dallas A211
12 15 Denver F654
48 8 WashDC A211
Example of a Relational Database

Customer
CustID Name Balance City SaleNo
132 Black 2000.00 Dallas 10
135 Tom 129.89 Denver 12
198 Tom (132.90) Dallas 10
SalesNO is PK in Sales table and FK in Customer table
Sale
SalesNO Rate City Dept#
10 10 Dallas A211
12 15 Denver F654
48 8 WashDC A211

S-ar putea să vă placă și