Each entity in a collection shares a certain number of characteristics. Each type of fruit might have the following relevant characteristics:
This list of characteristics is called fields. The fields are the characteristics which describe one record. All of the records in the database must have the same fields, but the values of those fields will be different. For example, all of the fruit in the database will have a name, but the names will be different. One record will have a name field with the value 'Bananas', and another record's name field will have the value 'Apples.' A field can be thought of as a detail of a record.
Fields represent units of the computer's memory. Because the computer stores different kinds of information in different ways, each field must have a specified data type. When you create a database, you need to tell the computer what kind of data each field will be so it knows how to store the information.
Data types in databases get a little more specific than you have seen before, because databases have more specialized ways of storing things in memory. Here's a few of the common ones:
You are already familiar with text from spreadsheets, but now we also have to specify a length. This has to do with the way that databases find records. All records in a database must be the same length (number of bytes in memory), so you have to specify the length of each text field. You might give a field that will hold state names a length of two characters, for example, and a 'first name' field a length of fifteen characters.
So why not just give each text field a big length, like 500 characters?
An integer is a whole number (no fractions or decimals) including zeroes and negative numbers. (...and you told that seventh grade math teacher you would never need this stuff again!!! ) Integers are pretty easy for the computer to work with and store. Sometimes you will come across long integers, which are also integers, but stored in a different way that takes more memory but allows for larger (and smaller) values.
Real numbers are integers and decimal values. As you may remember, the computer has to use a special form of exponential notation to store them in the computer. You might encounter 'super real numbers' (often called double-precision real numbers) These are real numbers that take more memory to store, but allow more decimal places.
Logical values (also sometimes called boolean or binary values) are values that can be expressed in terms of 1/0, yes/no, true/false, on/off, and so on. Binary fields take very little memory. (Think about it, you know how much they take!) They can be surprisingly useful. For example, in our fruit example the field that relates to whether the fruit has spoiled might be a binary field. Most of the time you can direct the database to use a yes / no or true / false notation rather than 1 / 0, but of course the 1/0 value is closest to what the computer stores.
As we discovered with spreadsheets, dates are not exactly text, and not exactly numbers. Spreadsheets usually think of them as numbers, but databases often are a little more sophisticated about dates, and give them their own data type. You often have a great deal of flexibility about how the dates are displayed to the user, but they are stored basically as numbers.
There are a number of other data types available. Many database management systems allow you to store other kinds of stuff such as variable-length memos, pictures, sound files, and whatever. Some even let you create your own data types.