411 REFERENCE · Wikibooks
A-level Computing 2009/AQA/Problem Solving, Programming, Operating Systems, Databases and Networking/Databases/Databases
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Primary keys
Table
In our database we will store information about 'things', or more technically, entities. To store data about things we use Tables. Each table will store data about a particular thing. Let's look at two examples:
Database: Crime in a local area
Tables: Crimes, Victims, Criminals, Police Officers
And looking at another example that you might be familiar with, a social networking site:
Database: Social Network
Tables: People, Relationships, Messages, Pictures
1 Exercise: Picking Tables
List the tables you might need to store a database on a football League
Team
Player
Match
Stadium
Referee
List the tables you might need to record details for an online store
Staff
Products
Receipts
Customers
Attribute/Field
Now we have gotten to grips with recognising the main tables we need to store in each database, we need to recognise what fields of data will be stored in each of these tables. The data items to be stored are called the attributes. Taking the Criminal database as an example:
Table: Criminal
Attributes:
Name: String
Date of Birth: Date
Number of scars: Integer
Home town: String
Note that for each of the attributes we are listing the attribute name and the field type, when building a database it is very important that we get the correct field type to prevent errors when entering data. Let's take a look at another example from the criminals Database
Table: Crimes
NI Number: String
Description: String
Type of crime: String
Severity: Integer
Date of Crime: Date
Victim ID: Integer
Criminal ID: Integer
1 Exercise: Picking attributes
For a social networking site, what attributes and data types would you include for the table of people
Name: string
Date of Birth: Date
Gender: string (character might also work here)
Public profile: boolean
Personal description: String
For a social networking site, what attributes and data types would you include for the table of relationships (the table that stores 'friend' 'sister' 'father' etc)
Person1 ID: integer
Person2 ID: integer
Type of relationship: string
Date created: Date
Records