NOS : Certificate in Computer Applications
| Home | Table of Contents |


Up: Online Course Material


LESSON 20

INTRODUCTION TO DATABASE

20.1 INTRODUCTION

All of us are familiar with the term data. In fact, unknowingly we come across data in our day to day life everyday. The age of a person, price of potato, number of students in a school, pin code of a city, etc. are some examples of data. In our life we have to remember so much of data. But it is easier for us to remember all information for a few individuals. For example, you may be in a position to tell accurately the age, height, complexion, income, educational qualification, residential address, etc. of your close friends. But it is too difficult for you to memorise all these information for a large number of individuals. Let us consider the example of National Open School (NOS). Every year about one lakh students take admission in NOS. If you are asked to memorise records of date of birth, subjects offered and postal address of all these students, it will not be possible for you.

To deal with such problems we construct a database. We arrange all information about students in a tabular form. We keep all the records so that if I am asked, ‘How many students are there in Economics?’ I am in a position to answer.

20.2 OBJECTIVES

After going through this lesson you will be in a position to

20.3 What is A Database?

Let us begin with the concept ‘database’ and its management. Database is a collection of information in a structured way. We can say that it is a collection of a group of facts. Your personal address book is a database of names you like to keep track of, such as personal friends and members of your family.

Let us look into our earlier example of information on students in NOS. A sample of 5 students is presented in the table below (see, Fig. 20.1). We have given 6 items of information on every student, namely, Roll No, Name, Date of birth, Sex, Postal address and Subjects offered by the student.

Fig. 20.1 contains required details about each student. There are six pieces of information on each student. They are Roll No, Name, Date of birth, Sex, Address and Subjects. Each piece of information in database is called a Field. We can define field as the smallest unit in a database. Each field represents one and only one characteristic of an event or item. Thus there are six fields in this database.

ROLL NO NAME DATE OF BIRTH SEX ADDRESS SUBJECTS
9721001 Subrat Das 21.05.1980 M C36, Sector 2, Bhubaneswar Orissa Pol Sc, Eco, History, Eng, Hindi
9721002 Aditya Bhoi 12.06.1981 M At/Po. Burla, Sambal Pur Phy, Chem, Biology, Eng, Hindi
9732012

 

Madhu Jain 03.01.1979 F A31, Pilani, Rajasthan Pol Sc, Eco, History, Eng, Hindi
9724004

 

Ahmad Ali 23.11.1979 M 12A, Sheikh Sarai-I, New Delhi Phy, Chem, Biology, Eng, Hindi
9715023

 

C. Suresh 07.09.1980 M 96, Malviya Nagar, Bhopal Pol Sc, Eco, History, Eng, Hindi

Fig. 20.1

If you take a close look at all these fields, they are not of the same type. Date of birth is date type whereas Name is character type. In database there can be five categories of fields.

They are:

We will discuss about each type of field in detail later on in this lesson. First let us be familiar with another concept that we will use frequently.

All the related fields for a particular event is called a Record. In the example above, all six fields taken together for a particular student is called a record of that student. Hence, since there are six students there are six records. Thus, we can define record as a collection of logically related fields.

Now we are in a position to define database in a formal manner. We can say that it is a collection of logically related records. In other words a database is a collection of database files, and each database file is a collection of records.

The task before us is creation of a database and its management. Data management involves creating, modifying, deleting and adding data in files, and using this data to generate reports or answer queries. The software that allows us to perform these functions easily is called a Data Base Management System (DBMS). Using a DBMS files can be retrieved easily and effectively.

There are many DBMS packages available in the market. Some of them are:

There are some WINDOWS based database packages available in the market such as MS ACCESS (part of MS OFFICE). In this lesson we will discuss about the package dBASE III + which is a DOS based package. It provides many choices to work with the program. This means you can work through both assist screen and dot prompt. It allows you to work with both financial figures and text.

20.4 HOW TO START dBASE III PLUS?

You can invoke dBASE III + either from Hard disk or from floppy drives. In these days more and more people are using the Hard disk to run the program. The computer systems with two floppy drives and no Hard disk are obsolete now. However, we will discuss the procedures to invoke dBASE III + in both Hard disk and floppy drives systems.

Let us begin with the procedure of loading dBASE III + into systems with Hard disk. The steps that you should follow are

  1. Start the computer in the DOS mode. The C prompt will appear on the screen. It will look like C:\>.
  2. You have to change the directory to come into dBASE III +. Type CD\DBASE and press ENTER key. You can type either lower case or upper case alphabets. The computer does not distinguish between the two.
  3. On the screen you will see C:\DBASE>.
  4. Type DBASE and press ENTER key. The computer will take a few seconds to show the copyright and logo of dBASE III + on the screen.
  5. Press ENTER key again. The dBASE III + logo will disappear from the screen and main menu of dBASE III Plus will appear. Now you are inside the dBASE III + program.

Now let us discuss how to load dBASE III + from floppy drives. Suppose your system does not have a hard disk and there are two floppy drives. Note that dBASE III + comes in two diskettes: system disk # 1 and system disk # 2. You have to obtain both the diskettes before loading the dBASE III + in your computer. The steps that you have to follow are:

  1. As you start the computer on the DOS mode you see C:\> on the top left corner of the monitor. Insert system disk # 1 in drive A.
  2. Type A: The prompt will change to A:\>
  3. Type dBASE and press ENTER key.
  4. After a few seconds the screen will display details of the dBASE III + package like name, version, etc. The bottom of the screen will contain the message,
  5. ‘INSERT SYSTEM DISK # 2 AND PRESS ENTER key’.
  6. Remove the system disk # 1 from drive A and insert system disk # 2.
  7. Press ENTER key. After a few seconds main menu of dBASE will appear on screen.

As the computer displays the main menu of dBASE III + your monitor will look somewhat like Fig. 20.2.

 

dBASE III + version 1.0 IBM/MSDOS

Copyright © Ashton-Tate 1984, 1985, 1986. All Rights Reserved.

dBASE, dBASE III, dBASE III +, and Ashton-Tate

are trademarks of Ashton-Tate

You may use the dBASE III + software and printed materials in the dBASE III + software package under the terms of the dBASE III + Software License Agreement. In summary, Ashton-Tate grants you a paid-up, non-transferable, personal license to use dBASE III + on one microcomputer or workstation. You do not become the owner of the package, nor do you have the right to copy or alter the software or printed materials. You are legally accountable for any violation of the License Agreement or of copyright, trademark, or trade secret laws.

 

Press the F1 key for HELP

Command Line               |<C:>|

 

Type a command (or ASSIST) and press the ENTER key.

Enter a dBASE III + command.

Fig. 20.2

 


Top

 

IN-TEXT QUESTIONS 1

  1. Define field, record, file, and database briefly.
  2. Name three DBMS packages.
  3. Write True or False
    1. In database there can be six categories of fields.
    2. A database is a collection of logically related records.
    3. Date of birth is character type field.
    4. You can invoke dBASE III + either from Hard disk or from floppy drives.
    5. Paradox is a DBMS package.

 


Top

20.5 How to create a database?

20.5.1 Creating a Database

When you want to create a database you have to take care of the following steps: You have to specify the database file structure such as

  1. Saving the database structure
  2. Entering data into the file as records

20.5.2 File Name

20.5.3 Field names

20.5.3 Field Types and Widths

In the beginning we had mentioned that there are five types of fields. Let us discuss them in detail.

  1. Character: This type of field contains textual matter. For example, name, address, special symbols, numbers and blank spaces. Character field can contain up to 256 characters or bytes. In Fig. 20.1 the fields Name, Address, Sex and Subjects are character types.
  2. Numeric: This type of field contains integers or decimal numbers, either positive or negative. The maximum length of numeric field is up to 19 digits long.
  3. Date: Date fields are 8 characters long. It is in the form of MM/DD/YY where MM is the month, DD is the day of the month and YY is the year. In Fig. 20.1 the field Date of Birth is of date type.
  4. Logical: It contains either a 'true' or 'false' (YES or NO) value. Its length is one character or one byte.
  5. Memo: Memo fields are used to store large block of text or tabular information. During data entry it is activated by pressing CTRL+HOME and completed by pressing CTRL+END. The field width of memo field is upto 5000 characters or bytes.

In order to create a new database you have to give the CREATE command at the dot prompt (see, Fig. 20.2). Let us create a new database file NOS. You have to type

. CREATE

and press ENTER.

On the screen you will find the following message:

Enter the name of the new file:

You have to type a file name, say, NOS and press ENTER. Remember that file name should not be more than eight characters in length. When you enter the file name you will see a screen as in Fig. 20.3. Here you have to specify the structure of your database. Remember you can type commands either in lower case or in upper case; dBASE III Plus does not distinguish between the two. Another point to remember is that in dBASE III Plus you can write the first four alphabets of a command instead of writing the whole command. For example, in place of CREATE if you can write CREA.

Bytes remaining: 4000

CURSOR a-lf.gif (847 bytes)  a-r.gif (846 bytes)

Char:       a-lf.gif (847 bytes)  a-r.gif (846 bytes)

Word: Home End

Pan:  ^   a-lf.gif (847 bytes)  a-r.gif (846 bytes) ^

INSERT

Char:        Ins

Field:        ^N

Help:         F1

DELETE

Char: Del

Word: ^Y

Field: ^U

Up a Field: ­       a-up.gif (854 bytes)

Down a Field:    a-dn.gif (853 bytes)

Exit/Save:           ^End

Abort:                   Esc

Filed Name   Type              Width        Dec    Filed Name   Type      Width      Dec

1. ............ . . Character          .        .      .           . .

CREATE             <C:>            NOS                   Field: 1/1 |

Enter the Field Name.

Field names begin with a letter and may contain letters, digits and under scores

Fig. 20.3

Suppose the name of the first field is ROLLNO. Hence you have to type in ROLLNO against the highlighted space below field name and press ENTER. The cursor will jump automatically to the column Type. Here by default the Field type is 'Character'. You can change it to other field types by typing the first alphabet of the field type you want. For example:

C for character, N for numeric, D for date, L for logic and M for memo. For ROLLNO the field type is Numeric. Hence you type in N. The cursor automatically moves in to the column Width. Here you have to specify the number of digits the field ROLLNO has and press the RIGHT ARROW key. Cursor will move to the last column Dec asking you to specify the number of decimal places the field contains. Since ROLLNO does not contain any decimal number you have to press ENTER only. The cursor will move automatically to the second record. Your screen will look like Fig. 20.4.

Here you have to give specifications for the second record and go on till all records are specified.

 

Bytes remaining: 4000

CURSOR a-lf.gif (847 bytes)  a-r.gif (846 bytes)

Char:       a-lf.gif (847 bytes)  a-r.gif (846 bytes)

Word: Home End

Pan:  ^   a-lf.gif (847 bytes)  a-r.gif (846 bytes) ^

INSERT

Char:        Ins

Field:        ^N

Help:         F1

DELETE

Char: Del

Word: ^Y

Field: ^U

Up a Field: ­       a-up.gif (854 bytes)

Down a Field:    a-dn.gif (853 bytes)

Exit/Save:           ^End

Abort:                   Esc

Filed Name      Type              Width        Dec            Filed Name   Type      Width      Dec

1. ROLLNO     Numeric           .5                . .
2.                      Character         .5                . .

 

CREATE             <C:>            NOS                   Field: 2/2                                         |

Enter the Field Name.

Field names begin with a letter and may contain letters, digits and under scores

 

Fig. 20.4

Once you have created a structure you want to use, you can save it in your disk.

Then you have to save the structure by pressing CTRL+W or CTRL+END

At this point the computer will prompt you

Press ENTER to confirm. Any other key to resume.

Once you press the ENTER key you will find another message:

Input data records now? (Y/N)

If you want to type in data then press Y. The computer screen will look like Fig. 20.5.

 

Bytes remaining: 4000

CURSOR a-lf.gif (847 bytes)  a-r.gif (846 bytes)

Char:       a-lf.gif (847 bytes)  a-r.gif (846 bytes)

Word: Home End

Pan:  ^   a-lf.gif (847 bytes)  a-r.gif (846 bytes) ^

INSERT

Char:        Ins

Field:        ^N

Help:         F1

DELETE

Char: Del

Word: ^Y

Field: ^U

Up a Field: ­       a-up.gif (854 bytes)

Down a Field:    a-dn.gif (853 bytes)

Exit/Save:           ^End

Abort:                   Esc

Filed Name      Type              Width        Dec            Filed Name   Type      Width      Dec

ROLLNO :    Numeric
NAME :       
BIRTH DATE :
SUBJECTS :

 

CREATE             <C:>            NOS                   REC.NONE

Fig. 20.5

Now you can enter data on the screen. As you know, data on a particular student is a record. Thus you have to enter as many records as you want. After completion of data entry you have to save it by pressing CTRL and END keys together (CTRL+END). Another method of saving a database is by pressing CTRL and W keys together (CTRL+W). If you want to quit dBASE without saving then you have to press ESC or CTRL+Q. At this point dBASE asks you if you really want to "Abort Editing? (Y/N)". You have to type Y for yes and N for no. If you type Y you will return to dBASE dot prompt and if you type N you can continue editing of your file.

20.6 OPENING AN EXISTING FILE

Just as you open a book in order to read it, a database file, existing on a floppy or a hard disk, also has to be opened. The USE command opens an existing database file so that it can be used for querying, reporting or editing.

Suppose you want to open the earlier created file BIODATA for further modification. You give the command:

.USE NOS

Note that when you save a database file in dBASE the computer gives an extension .DBF along with the file name. While opening a file, dBASEIII+ assumes it to be a .DBF file.

The USE command assumes that the file is to be loaded from the default or active drive, i.e. the drive from which dBASE was invoked. If the file is on a floppy, you have to instruct dBASE III+ to make the A drive as the active work drive, rather than the C drive. This can be done by the following command:

. SET DEFAULT TO A:

On selecting a work drive, all subsequent commands will apply to that drive.

20.6.1 Viewing the Contents of the File

After opening the file BIODATA you may like to see its content. This you can do by the LIST command.

.List

The screen will look like Fig. 20.6.

. list

No database is in USE. Enter file name: biodata

Record#

NAME

SEX

AGE

1

Anant

m

25

2

Babloo

m

13

3

Manju

f

30

4

Sibu

m

12

5

Soma

f

8

Command Line <C:>BIODATA Rec: EOF/5

Type a command (or ASSIST) and press the ENTER key.

Enter a dBASE III PLUS command.

Fig. 20.6

Since there are 5 records only in the database we are dealing with all the records are visible on a single screen. When all the records cannot come on a single screen the records scroll down and you cannot see the records in the beginning. In order to overcome this problem you have to use the DISPLAY ALL command.

The .Display All command displays a screen full of records and pauses, until the user presses a key to continue.

Press the F1 key for HELP.

. use biodata

. display

Record#

NAME

SEX

AGE

1

Anant

m

25

 

Command Line |<C:>|BIODATA |Rec: 1/5 | |

Type a command (or ASSIST) and press the ENTER key.

Enter a dBASE III PLUS command.

Fig. 20.7

20.7 ADDING RECORDS

Suppose some new students have taken admission in National Open School. You want to add these student records to the existing file BIODATA. In order to do so you have to use the APPEND command. The APPEND command displays a blank record for data entry. Once the data has been entered, it presents another blank record. This process continues till the user presses CTRL+END

 

Bytes remaining: 4000

CURSOR a-lf.gif (847 bytes)  a-r.gif (846 bytes)

Char:       a-lf.gif (847 bytes)  a-r.gif (846 bytes)

Word: Home End

Pan:  ^   a-lf.gif (847 bytes)  a-r.gif (846 bytes) ^

INSERT

Char:        Ins

Field:        ^N

Help:         F1

DELETE

Char: Del

Word: ^Y

Field: ^U

Up a Field: ­       a-up.gif (854 bytes)

Down a Field:    a-dn.gif (853 bytes)

Exit/Save:           ^End

Abort:                   Esc

Filed Name      Type              Width        Dec            Filed Name   Type      Width      Dec

NAME :       
SEX :
AGE :

 

APPEND             <C:>            BIODATA                  REC.EOF/5

Fig. 20.8

 


Top

IN-TEXT QUESTIONS 2

1. What are the different types of fields in dBASEIII+.

2. What is the usefulness of the following commands: APPEND, LIST, CREATE.

3. Write True or False

(a) The field name can be a maximum of 10 characters.

(b) The maximum width for a character type field is 250.

(c) The width of a logical field is 2 digits.

(d) Character field is used for mathematical calculation.

(e) A field name should always start with an alphabet.

20.8 WHAT YOU HAVE LEARNT

In this lesson we discussed the concept of database and the software available to manage it. The different methods to invoke dBASE III Plus are discussed. We have also explained the different types of fields in a database. Now you should be in a position to create a new database, add records to an existing database and see the contents of a database.

20.9 TERMINAL QUESTIONS

  1. What are the different methods to start dBASEIII+ ?
  2. Explain in brief the following field types:
    Character field, Date field, Numeric field and Memo field.
  3. What are the advantages of dBASEIII+?
  4. How do you add records a database?

 

20.10 FEEDBACK TO IN-TEXT QUESTIONS

IN-TEXT QUESTIONS 1

  1. Each piece of information in database is called a Field. Field is the smallest unit in a database. All the related fields for a particular event is called a Record.
  2. FoxBASE, dBASE, Clipper
  3. (a) False (b) True (c) False (d) True (e) True

IN-TEXT QUESTIONS 2

  1. There are five types of fields in database. They are Character, Numeric, Date, Logic and Memo.
  2. Create command creates a new database. List command displays all the records in a database. The Append command displays a blank record for data entry.
  1. (a) True (b) False (c) False(d) False(e) True

Top