31
Databases The basics of Access

Databases

  • Upload
    angus

  • View
    30

  • Download
    0

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

Page 1: Databases

Databases

The basics of Access

Page 2: Databases

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?

Page 3: 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?

Page 4: Databases

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

Page 5: Databases

A field = 1 piece of data in a record.

pupilID

Surname

Firstname

Postcode

Fieldname

{ Record

FieldnameFieldnameFieldname

Fields

Page 6: Databases

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

Page 7: Databases

• Interface• The 2x different views we work in

o Datasheet and Design views

Demonstration in Access

Page 8: Databases

• 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

Page 9: Databases

Datasheet View

Design View

Field Names

MS Access

Page 10: Databases

MS Access

Page 11: Databases

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.

Page 12: Databases

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

Page 13: Databases

• Validation lets us check for errors or invalid data.

• The tools we use:

Validation Rules

Input Masks&

Field Validation

Page 14: Databases

Input Mask Rules

Page 15: Databases

• 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

Page 16: Databases

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

Page 17: Databases

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

Page 18: Databases

• 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

Page 19: Databases

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

Page 20: Databases

This shows the two tables joined by the field “country”.

Related Tables

Page 21: Databases

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

Page 22: Databases

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

Page 23: Databases

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

Page 24: Databases

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

Page 25: Databases

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

Page 26: Databases

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

Page 27: Databases

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

Page 28: Databases

Primary Keys

Primary Keys

Page 29: Databases

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

Page 30: Databases

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

Page 31: Databases

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