Database Notes
Database Notes
Flat-file databases
A flat-file database stores its data in one table, which is organised by rows and
columns. For example, in the following database about teachers, each record (row) in the table
contains data about one person. Each column in the table
contains a field, which has been given a field name, and each cell in that column
has the same, predefined data type.
Relational databases
A relational database stores data in more than one linked table, stored in a file.
Relational databases are designed so that the same data is not stored many times. The
tables within a relational database are linked with relationships (hence the name).
Key fields
Each table within a relational database will have a key field. The relationships
linking the tables use these key fields
If the data is split into two tables – one for the teachers and one for the
students – that are linked together, it can be stored and retrieved more
efficiently, like this:
These two tables are linked with a ‘one-to-many’ relationship, because one
teacher’s record is linked to many students’ records. The primary key fields (which
must contain unique data) are the Student_ID and Teacher_ID
Data types and sub-types
Alphanumeric data can store alpha characters (text) or numeric data
(numbers) that will not be used for calculations. In Access this is called a text
field.
» A numeric data type (as the name suggests) is used to store numeric values
that may be used for calculations. This does not include numeric data such as
telephone numbers, which should be stored in an alphanumeric data type.
In Access this is called a number field. There are different types of numeric
field including:
– integer sub-type, which stores whole numbers. In Access you can select an
integer field or a long integer field. It is wise to use a long integer field if
it is going to contain three or more digits
– decimal sub-type, which will allow a large number of decimal places, or a
specified restricted number if this is set in the field properties when the
database is created
– currency sub-type, which will allow currency formatting to be added to the
display. This includes currency symbols and regional symbols. The database
does not store these symbols as this would use up valuable storage space
– date and time sub-type, which stores a date and/or time as a number.
» A Boolean (or logical) data type stores data as 0/-1 but can display it as Yes/
No (or True/False, 0/1).