Upload
angus
View
30
Download
0
Tags:
Embed Size (px)
DESCRIPTION
Databases. The basics of Access. Database Basics. A database is an organised collection of information . For example A telephone directory is a database It stores your name your address your telephone number It is organised information. - PowerPoint PPT Presentation
Citation preview
Databases
The basics of Access
Database Basics
For exampleA telephone directory is a databaseIt stores your name
your addressyour telephone number
It is organised information
This information is all about you. It’s all related to you.
A database is an organised collection of information.
What are some examples of databases?
For exampleYour record in the telephone directory
your nameyour addressyour telephone number
This information is all about you. Its all related to you. Its your record.
A record is one batch of related information
What’s in a record?
Records are often presented in a tableThis table belongs to database containing information about pupils in a school.
Surname Address Telephone NumberAbel RMTC
Bourne01778 422365
Jones 1 Edinburgh CrescentBourne
01778 423564
Smith 2 Edinburgh CrescentBourne
01778 398574
Weston 3 Edinburgh CrescentBourne
01778 396547
How many records does this table store?
Records held in tables
A field = 1 piece of data in a record.
pupilID
Surname
Firstname
Postcode
Fieldname
{ Record
FieldnameFieldnameFieldname
Fields
Give some examples of appropriate field names for each of the following tables
Police database of criminalsSurnameFirstnameAddress
Videos available for hire in a video clubTitleDate hiredDate to be returnedCustomer ID
Members of Video ClubSurnameAddressTelephone Number
Books in libraryTitleAuthorISBN Number
Fieldnames
• Interface• The 2x different views we work in
o Datasheet and Design views
Demonstration in Access
• We are going to be working mainly in two different views.
Datasheet View when entering new records
Design View when creating new tables
Access View
Datasheet View
Design View
Field Names
MS Access
MS Access
Task - Creating a new table
• The P.E department have requested a database on with relevant student sporting information.
• You will create a new table in MS Access to record this information from your classmates.
• What fields will we require?
• You need to include at least 5 of your classmates information.
Surname Eye Colour
Address Town Telephone Number
Abel Blue RMTC Bourne 01778 422365
Jones Blue 1 Edinburgh Crescent
Bourn 01778 423564
Smith Brown 2 Edinburgh Crescent
Bourn 01778 398574
Weston Bue 3 Edinburgh Crescent
Bourne 01778 396547
How many people live in Bourne?
Garbage in Garbage out
• Validation lets us check for errors or invalid data.
• The tools we use:
Validation Rules
Input Masks&
Field Validation
Input Mask Rules
• Every field has to be given a data type, the field has to be told what type of data can be expected in the field.
Fieldname DatatypeSurname TextAge NumberDate of Birth
Date/Time
Tuition Fees ???????Currency
Data types
What data types would you use for each of the following fields?
SurnameStart of holidayFlight number
Stock on shelf
Cost of holiday
TextDate/TimeText or NumberNumber
Currency
Field Name Data TypeExample of Data entered
Gray
21/12/2002BA345 or 6754
24
$250.50
Data types
A field can be assigned a size, this is the space allowed for the data to fill. For example a field that holds data on a persons title would not need to be too large as all it needs to accommodate would be Mr, Mrs, Miss or possibly doctor. So a field of 6 would be fine.What field size would you use for each of the following fields?
Postcode
House Number
Gender
Country
8
4
2 or 6
25
Field Size
• Flat file = all data in one tableo What we have done so faro What are the issues with this?
• Relationalo How is this of benefit to us?
• Storage• Speed• Organisation• Update efficiency
o How can we connect the tables?
Flat File vs Relational
Tables can be joined together allowing both table to be searched or sorted together.
The fields that are used to relate two tables MUST be of the same data type or they will not join. In this example both fields are text.
One common field must be in each table. In this example it is “Country”.
Relationships
This shows the two tables joined by the field “country”.
Related Tables
Pupil IDSurnameFirstnameFormDate of Birth
Tblpupil
Exam IDExam BoardExam TitleDate of ExamPupil ID
Tblexam
This database example is to track the exams pupils sit, it consists of 2 tables one for the pupil information and one for the exam information. The field Pupil ID has been used in the exam table to track which exams the pupils are sitting.
Primary key
Primary key
The pupil ID field is used in both tables
Relationships
Membership NoSurnameFirstnameAddressTelephone No
Tblcustomers
Video NumberVideo TitleGenreAge guideMembership No
Tblvideos
Which fields would you join in this table. The database is made of two tables tracking the hire of videos to the members.
Primary keyPrimary key
Relationships
A primary key is the unique key that identifies that record.
pupilID
Surname
Firstname
Postcode
Which field would you use as the primary key?
Primary Keys
A primary key is a unique field that identifies the record
pupilID
Surname
Firstname
Postcode
What field would you identify as the primary key?
Primary Key
Primary Keys
This is the table we created to hold information about your classmates, we left the primary key as ID and AutoNumber.
While this works, having a field like this is a little meaningless. What other field could we use to uniquely identify each student?
Primary Key
Primary Keys
If we changed the name of the field to StudentID it would have more meaning. Is this OK?
This would work, BUT do we want automatic numbers? Probably not, it would be better if we could type in the unique student ID for each student.
Primary Key
Primary Keys
What field from each table would you use as the primary key
Exam NumberExam Title
Exam BoardDate of examLength of exam
This table hold details of exams that students can be entered for
Stock CodeDescription
Quantity heldMax Stock LevelMin Stock Level
This table holds information on stock
Primary Key
Primary Key
Primary Keys
Primary Keys
Primary Keys
Foreign Key – a primary key used in another table for example the country is the primary key in the Countries and the foreign key in the RWCTeams.
Primary Key
Primary Key
Foreign Key
Foreign Keys
Pupil IDSurnameFirstnameFormDate of Birth
Tblpupil
Exam IDExam BoardExam TitleDate of ExamPupil ID
Tblexam
This database example is to track the exams pupils sit, it consists of 2 tables one for the pupil information and one for the exam information. The field Pupil ID has been used in the exam table to track which exams the pupils are sitting. It is the primary key in the pupil table and the foreign key in the exam table.
Primary key
Primary key
Foreign Key
Foreign Keys
Customer IDSurnameFirstnameTelephone NoDate joined
Tblcustomer
Video NoTitleAge GuideDate hiredCustomer ID
Tblvideos
In this database what would be the primary key, the foreign key and which fields would be joined.
Primary key
Primary key
Foreign Key
Video Club