麻豆官网首页入口

Storing data in tables

Databases store data in tables. Tables are made up of fields and records.

A prison might use a database to keep records of its inmates. A criminal鈥檚 record may contain the following fields:

  • first name
  • last name
  • height
  • crime
  • release date

A table consists of related records, eg people convicted of a crime, and a record consists of related fields, eg Paul Smith who is 1.8 m, committed a robbery and is being released on 26.01.2015.

Crime database report

Creating a table

To create a table in Microsoft Office Access, use Design view. Start by writing a list of sensible field names, eg 鈥楥rime鈥 would be a better field name than 鈥楢ct of questionable judgement鈥 because 鈥楥rime鈥 is short and to the point.

Data types

Access will automatically choose a field鈥檚 type based on the data entered. For example, if a phone number is entered into a field its data type will be automatically set to 'Number'. Other data types include:

  • 'text' 鈥 writing
  • 'date/time' 鈥 date or time
  • 'currency' 鈥 euro, pound, dollar, etc
  • 'autonumber' 鈥 number increases by one each time
  • 'yes/no' 鈥 only yes or no can be entered

Setting a primary key

The primary key is a field that contains data that is unique for each record. A car dealership may use a car's registration or number plate as a primary field to set apart two cars of the same colour, make and model.

More guides on this topic