Sudha Aravindan has taught high school Math and professional development in Information Technology for over 10 years. Sudha has a Doctorate of Education degree in Mathematics Education from the University of Delaware, USA, a Masters degree in English Literature from the University of Kerala, India, a Bachelor of Education degree in Teaching of Math from the University of Kerala, India, and a Bachelor of Science degree in Math, Physics and Statistics from the University of Kerala, India. Sudha has a certificate in Java programming and Statistical Analysis.
Database Fields: Definition & Types
Overview of Database Fields
A database is a collection of tables. Each table has fields, or containers, to hold the data, and each table contains rows of data, which are also called records.
Consider a student table that stores data about students in a class, like this one here:
Student Table
student-id | student-name | student-email |
---|---|---|
054 | Joe | j@email.com |
055 | Kate | k@email.com |
056 | Laura | l@email.com |
057 | Mike | m@email.com |
As we can see, the fields in this table (which are the containers that hold the data) are:
- Student-id
- Student-name
- Student-email
This table has four rows of data. Each row is a database record. A record for this table contains all the information about one student. Each of the columns of the table, (student-id, student-name, and student-email) are the database fields. In this table, record 1 is data about the student Joe, his student ID is 054, and his email is j@email.com.
Each database field defines a unique piece of data. A table contains only one field of each kind. For example, the student table will have only one field each for student ID, student name, and student email. There will not be two student ID fields, for instance.
Example
The fields in the student table can be described as follows:
- Student-id: is an ID assigned to each of the students
- Student-name: is the first and last name of each student
- Student-email: is the email address of each student
The database field names are descriptive of the data they contain. When you see the field 'student-id' you can tell that this field contains the ID of each student. And when you see the 'student-email' field, you can tell that this field contains the email address of each student.
In the database table, each field is in a column. In the above example, 'student-id' is in the first column, 'student-name' is in the second column, and 'student-email' is in the third column.
When a database table is created, the fields have to be determined to help decide what kind of data will be stored in the table. This is like saying that when a house is built, you have to decide how many rooms there will be and what the function of each room is. For example, you would have a kitchen where you do your cooking, a living room where you relax, and so on. Similarly, in the student table, you define a field, or container, called 'student-id' to save the student IDs of all students; you define a field, or container, called 'student-name' to save the names of all students; and so on.
Database Field Types
In addition to defining the fields for a database table, you also have to specify what kind of data each field will contain. Supposing you are packing for a move, and you have all your furniture and household goods in boxes. When packing the kitchen for instance, you would have a box for glassware, another box for silverware and cutlery, and yet another box for dishes. In the same way, when you create a database table for student data, you need to define the types of data in each field. For example the 'student-name' field will contain only characters from the alphabet. The 'student-id' field in this table has only numeric or number values, such as 054, 055, etc.
Here are some common types of database fields. We'll look at the datatype and pair it with the appropriate definition:
Common Types of Database Fields
- Character: This field stores only alphabet values; sometimes the 'Character' field is called a 'Text' field
- Boolean: This field stores only true or false values
- Integer: This field can store only integer values, which means that no decimal values can be saved in this field
- Decimal: This field can store decimal values
- Date: This field can store day, month, and year date values
- Timestamp: This field can store hour, minute, and second values, in addition to date and time values
Each of the field types has a formal mathematical name; for example, 'Character', 'Boolean', and so on. However, these names could be different in different types of databases ; in Access databases, for instance, a 'Character' value is called 'Text', and in Oracle databases, it is called a 'VarChar'.
Example
Sally has a small antiques store. She has a database table to store a description of items purchased and the cost of each item. What database field types would she define?
Solution:
Sally could define the database field types as follows:
items-purchased | cost-per-item |
---|---|
Character or Text | Decimal |
Here there are two database fields:
- items-purchased, and
- cost-per-item
The database field types determine what kind of data can be stored in each field. Only character or text data can be stored in the items-purchased field. And currency values can be stored as decimal numbers in the cost-per-item field.
Lesson Summary
When you create a database table, you first define the fields to determine the kinds of data that can be stored in the table. Each database table has fields, or containers to hold the data, and rows of data, which are also called records. The fields should be defined to determine what kind of data they can contain.
Some of the common field types we looked at are as follows:
- Character: This field stores only alphabet values; sometimes the 'Character' field is called a 'Text' field
- Boolean: This field stores only true or false values
- Integer: This field can store only integer values, which means that no decimal values can be saved in this field
- Decimal: This field can store decimal values
- Date: This field can store day, month, and year date values
- Timestamp: This field can store hour, minute, and second values, in addition to date and time values
Different databases sometimes name the field types differently. For example, the 'Character' data type in Excel is the same as the 'Text' data type in Access.
To unlock this lesson you must be a Study.com Member.
Create your account
Register to view this lesson
Unlock Your Education
See for yourself why 30 million people use Study.com
Become a Study.com member and start learning now.
Become a MemberAlready a member? Log In
Back