Lane Medical Library & Knowledge Management Center
A Painless Introduction
to MS Access Databasing
Yannick Pouliot, PhD
Bioresearch Informationist
Lane Medical Library & Knowledge Management Center
4/20/07
Lane Medical Library &
Knowledge Management Center
2
Preliminaries
Launch MS Access
Open Simple1.mdb
File/Open
Using the Help don’t neglect it!
Exercise: ask the Office Assistant for “select syntax”
Lane Medical Library &
Knowledge Management Center
3
Contents
Familiarization with MS Acces
Understanding a simple database
Basics of SQL querying
Creating a simple database
Loading database via MS Excel
Tools for running SQL queries
Installation (Windows)
Selected databases
Resources & cheat sheet
Lane Medical Library &
Knowledge Management Center
4
Resources – MS Access
Available as eBook
Available as eBook
Lane Medical Library &
Knowledge Management Center
5
Resources – Excel/MS Query
In Lane catalog
Lane Medical Library &
Knowledge Management Center
6
Resources – MS Access
Free Online Training Resources
Using an Access database to store and information (2 min)
/>
Creating a database from Excel (5 min):
/>
Creating tables in Access (50 min):
/>61033
Writing queries (50 min):
/>AssetID=RC010776611033
Lane Medical Library &
Knowledge Management Center
7
Why Bother
with MS
Access?
Lane Medical Library &
Knowledge Management Center
8
Why MS Access?
More: />Lane Medical Library &
Knowledge Management Center
9
Definitions,
Definitions…
Lane Medical Library &
Knowledge Management Center
10
Definitions
Database: Collection of tables
Table
Collection of records that share a common fundamental characteristic
E.g., patients and locations can each be stored in their own table
Schema
A view that inter-relates tables to each other
Record
Basic unit of information in a relational table
E.g., 1 record per person
A record is composed of fields
Query
Set of instructions to a database “engine” to retrieve, sort and format
returning data.
E.g., “find me all patients in my database”
Database engine
Software application that stores the data and enables querying
Lane Medical Library &
Knowledge Management Center
11
Table and Field Definitions
How It Looks In Access…
Lane Medical Library &
Knowledge Management Center
12
Main Relational Database Engines
Oracle
MS Access
MS SQL Server
Filemaker
MS SQL Server
MySQL
Postgress
Sybase
Lane Medical Library &
Knowledge Management Center
13
Understanding
Relational
Databases
Lane Medical Library &
Knowledge Management Center
14
Understanding the Relational Principle: A
Simple Database
Every patient gets ONE record in the Patients table
Every visit gets ONE record in the Visits table
Rows in different tables can be related one to another using a shared
key (identifier number unique to table)
There can be multiple visits records for a given patient
There can be multiple tissue records for a given patient
“join”
Lane Medical Library &
Knowledge Management Center
15
The Relational Principle in Action
Related records can be found using a shared key
Shared key = identifier that is:
unique to each table
Can be referenced by another table
Example: Patients.ID = Visits.PatientID
Lane Medical Library &
Knowledge Management Center
16
The Database Schema: Your
Roadmap For Querying
The schema describes all tables and all fields
Describes relationships between tables
Crucial in enabling retrievall of desired data
Simple example:
Very important
Must understand schema for accurate querying
Wrong understanding = wrong results
Lane Medical Library &
Knowledge Management Center
17
Example: The Schema for SRI’s
BioWarehouse System
Lane Medical Library &
Knowledge Management Center
18
Querying MS Access
or any relational database…
Lane Medical Library &
Knowledge Management Center
19
How Relational Databases Are
Queried
Querying = extracting information out of the database
… and into something, e.g., Excel
This is done using the Structured Query Language (SQL)
Lane Medical Library &
Knowledge Management Center
20
Introducing The SQL Select Statement
Good news: This is
the only SQL
statement you need to
understand for
querying
Exercise: run
SuperSimpleQuery1 in
Simple1 database
SELECT LastName, FirstName
FROM Patients
Lane Medical Library &
Knowledge Management Center
21
Basic Syntax of Select Statement
SELECT field_name
FROM table
[WHERE condition]
Example:
Select LastName,FirstName
From Patients
Where Alive = ‘Y’;
Important: Everything is MS Access is case sensitive
LastName ≠ lastName
[ ] = elective
Lane Medical Library &
Knowledge Management Center
22
Realistic
Querying With
the MS Access
Query Builder
Lane Medical Library &
Knowledge Management Center
23
A More Complete Description of Select
Statement
SELECT [DISTINCT|COUNT] field_list
FROM table_list
[WHERE conditions]
[GROUP BY field_list]
[ORDER BY field_list [ASC | DESC] ]
more: />pid=CH010410171033
Includes examples and descriptions of each SELECT operator (e.g.,
“group by”)
Lane Medical Library &
Knowledge Management Center
24
Meaningful Queries in Acces
Exercises - Database: Simple2.mdb
1. Returning ordered records
2. Counting records
LifetimeNumberFAQs1
Exercise: how many FAQs per day?
LifetimeNumberFAQs2
Demo: creating Pivot Tables
3. Generating averages
Querying from a query!
4. Change order of columns
5. Change sorting of rows
Lane Medical Library &
Knowledge Management Center
25
Uploading
Data in MS
Access