NOS : Certificate in Computer Applications
| Home | Table of Contents |
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
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:
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
IN-TEXT QUESTIONS 1
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
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.
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 |
||||
|
||||
| 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 |
||||
|
||||
| Filed Name Type
Width
Dec
Filed Name Type
Width Dec 1. ROLLNO
Numeric
.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 |
||||
|
||||
| Filed Name Type
Width
Dec
Filed Name Type
Width Dec ROLLNO :
Numeric
|
||||
| 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 |
||||
|
||||
| Filed Name Type
Width
Dec
Filed Name Type
Width Dec NAME
:
|
||||
| APPEND <C:> BIODATA REC.EOF/5 |
Fig. 20.8
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
20.10 FEEDBACK TO IN-TEXT QUESTIONS
IN-TEXT QUESTIONS 1
IN-TEXT QUESTIONS 2