Chapter 17
INTRODUCTION TO DATABASES
A
database is an organized collection of data where each data is related
to each other. The data contains useful information in the form of text,
numbers, and dates. You can retrieve any information stored in a database
at any time to make your decision quickly.
A Database Management System (DBMS) is the management of the data, i.e.,
storing, processing, and retrieving of data. The Relational Database Management
System (RDBMS) is the management of all related data.
Some commonly used RDBMSs are:
S. No. RDBMS Company Name
1. Oracle 8/8i/9i/11i ORACLE Corporation
2. Microsoft SQL Server 7.0/2000 Microsoft Corporation
3. Sybase SQL Server Sybase Incorporation
4. Informix Server Informix Software Incorporation
The database is made up of several tables.
315
316 SOF T WARE ENGINEERING AND TESTING
17.1 TABLES
A table is a group of data having similar information. All the data belong to the
same group. These data are further subdivided into several columns named Fields.
Each field may have different data types and sizes but they are related to each
other. The size of the field indicates the maximum amount of data that can be
entered into that field.
Let’s use an example of a school. Suppose a school has two departments:
1. Admission
2. Library
The Admission department does the admission of new students and collects
the following information about the student:
Name
Father’s Name
Date of Birth
Address
Monthly income
Name, Father’s Name, and Address are stored in an alphanumeric format.
Date of Birth is stored in a date type format and monthly income is stored in
numeric format.
The Library department purchases new books and maintains the record of the
books. The book’s information is stored in the following columns:
Book Name
Subject
Author
Publication
Date of purchase
Book Name, Subject, Author, and Publication, are stored in alphanumeric
format, date of purchase is stored in date type format, and book cost is stored in
numeric format.
Now we create a database for the school.
INTRODUCTION TO DATABASES 317
17.2 STRUCTURE OF A DATABASE
A Field may be alphanumeric, numeric, or a date type.
Field Name Field type Field size
Name Alphanumeric 50
Fname Alphanumeric 50
Dob Date 8
Address Alphanumeric 100
Income Numeric 8
Field Name Field type Field size
Bookname Alphanumeric 50
Subject Alphanumeric 20
Author Alphanumeric 50
Publication Alphanumeric 50
Purchase_date Date 8
Cost Numeric 8
17.3 KEYS
The main role of keys is to maintain data integrity in a database or table. Keys are
one of the following types:
1. Candidate Key: The column that has a unique value in all the rows is a
candidate key. The candidate key may be more than one in a table.
2. Primary Key: If any column is made a primary key, the data entered in that
column must be unique across the entire column. The primary key column
cannot be left blank. The primary key is one of the candidate keys.
3. Alternate Key: All candidate keys which are not primary keys are referred to
as alternate keys.
318 SOF T WARE ENGINEERING AND TESTING
4. Composite Key: If there is more than one field used as primary keys, the sets
of these keys are called composite keys.
5. Foreign Key: When a primary key of one table also exists in another table, it
is referred as a foreign key for the second table. The foreign key is used for
making a relation between both the tables.
17.4 DATA INTEGRITY
For a successful database operation there must be data integrity. There are three
types of data integrity.
1. Entity Integrity: Ensures that each record is unique and can be identified by a
primary key, because a primary key field contains a unique value.
2. Domain Integrity: Ensures column level validation, i.e., each value of the field
is validated before entering, whether it is correct or not, and only the correct
value is allowed to be entered.
3. Referential Integrity: Ensures that for each value of a foreign key, a primary
key exists in the master table.

Get Software Engineering and Testing now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.