Databases II: Microsoft Access

Similar documents
Implementing Table Operations Using Structured Query Language (SQL) Using Multiple Operations. SQL: Structured Query Language

Microsoft Access Illustrated. Unit B: Building and Using Queries

Introduction to MS Access queries

Access Intermediate

Access Intermediate

FIT 100 More Microsoft Access and Relational Databases Creating Views with SQL

PowerPoint Presentation to Accompany GO! All In One. Chapter 13

CSC Web Programming. Introduction to SQL

COMP 244 DATABASE CONCEPTS & APPLICATIONS

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Sloan School of Management

Microsoft Access XP Queries. Student Manual

Open an existing database Sort records in a table Filter records in a table Create a query Modify a query in Design view

Enforce Referential. dialog box, click to mark the. Enforce Referential. Integrity, Cascade Update Related Fields, and. Cascade Delete Related

Follow these steps to get started: o Launch MS Access from your start menu. The MS Access startup panel is displayed:

Microsoft Office Illustrated Introductory, Building and Using Queries

STIDistrict Query (Basic)

Exam 2 Study Guide. Denny Hood Computer Science 101

Unit Assessment Guide

In This Lecture. Yet More SQL SELECT ORDER BY. SQL SELECT Overview. ORDER BY Example. ORDER BY Example. Yet more SQL

HKTA TANG HIN MEMORIAL SECONDARY SCHOOL SECONDARY 3 COMPUTER LITERACY. Name: ( ) Class: Date: Databases and Microsoft Access

Microsoft Access XP (2002) Queries

3/3/2008. Announcements. A Table with a View (continued) Fields (Attributes) and Primary Keys. Video. Keys Primary & Foreign Primary/Foreign Key

Creating a Crosstab Query in Design View

Microsoft Access 2007 Level 3

Microsoft Office Access Learn how to use the Query window in Design view. Tutorial 3b Querying a Database

OVERVIEW OF RELATIONAL DATABASES: KEYS

Database Systems: Design, Implementation, and Management Tenth Edition. Chapter 7 Introduction to Structured Query Language (SQL)

Introduction to SQL. IT 5101 Introduction to Database Systems. J.G. Zheng Fall 2011

Objective 1: Familiarize yourself with basic database terms and definitions. Objective 2: Familiarize yourself with the Access environment.

Computing for Medicine (C4M) Seminar 3: Databases. Michelle Craig Associate Professor, Teaching Stream

Microsoft Office 2010: Introductory Q&As Access Chapter 3

Advanced Topics in Access: Queries

Tutorial 3 Maintaining and Querying a Database. Finding Data in a Table. Updating a Database

More on MS Access queries

Lecture 2: Chapter Objectives. Relational Data Structure. Relational Data Model. Introduction to Relational Model & Structured Query Language (SQL)

Microsoft Access 2016

Microsoft Access 2016

Lecture 2: Chapter Objectives

Access Objects. Tables Queries Forms Reports Relationships

What is SQL? Toolkit for this guide. Learning SQL Using phpmyadmin

Topics Covered in Video:

Logical Operators and aggregation

Microsoft Access XP (2002) - Advanced Queries

Database Management Systems by Hanh Pham GOALS

World Christian Database User Guide

Jarek Szlichta

Access Module 2: Building and Using Queries

Microsoft Access - Using Relational Database Data Queries (Stored Procedures) Paul A. Harris, Ph.D. Director, GCRC Informatics.

COMM 391 Winter 2014 Term 1

Polaris SQL Introduction. Michael Fields Central Library Consortium

STOP DROWNING IN DATA. START MAKING SENSE! An Introduction To SQLite Databases. (Data for this tutorial at

SQL. Char (30) can store ram, ramji007 or 80- b

Lesson 13 Transcript: User-Defined Functions

Name: Class: Date: Access Module 2

Step 1: Create a totals query to show the total cost price and total sale price of the wine for each supplier.

NCSS: Databases and SQL

Access - Introduction to Queries

T-SQL Training: T-SQL for SQL Server for Developers

Lesson 2. Data Manipulation Language

12. MS Access Tables, Relationships, and Queries

COMM 391. Objectives. Introduction to Microsoft Access. What is in an Access database file? Introduction to Microsoft Access 2010

CMPT 354: Database System I. Lecture 3. SQL Basics

II (The Sequel) We will use the following database as an example throughout this lab, found in students.db.

Concepts of Database Management Eighth Edition. Chapter 2 The Relational Model 1: Introduction, QBE, and Relational Algebra

Chapter 7 Equijoins. Review. Why do we store data for articles and writers in two separate tables? How can we link an article to its writer?

CHAPTER 6 SUMMARY. Objective 1: Identify Good Database Design

Data Manipulation Language (DML)

Level 6 Relational Database Unit 3 Relational Database Development Environment National Council for Vocational Awards C30147 RELATIONAL DATABASE

CGS 3066: Spring 2017 SQL Reference

Access 2007: Advanced Instructor s Edition

Microsoft MOS- Using Microsoft Office Access Download Full Version :

The Structured Query Language Get Started

Review. Objec,ves. Example Students Table. Database Overview 3/8/17. PostgreSQL DB Elas,csearch. Databases

U005: Advanced Query. U005 Advanced Query Ver 2.4

ACCESS DATABASES MODULE 5. AN OVERVIEW TO ENABLE FUTURE ECDL ADULT STUDY. A database Help and click sample databases

As your databases continue to evolve, you will need to incorporate advanced queries and reports. This chapter addresses how to create and use action

Based on the following Table(s), Write down the queries as indicated: 1. Write an SQL query to insert a new row in table Dept with values: 4, Prog, MO

Computer Skills MS Access Work Sheet # 1

EE221 Databases Practicals Manual

User Manual Mail Merge

Using Microsoft Access

SQL 2 (The SQL Sequel)

Technology In Action, Complete, 14e (Evans et al.) Chapter 11 Behind the Scenes: Databases and Information Systems

Shelly Cashman Series Microsoft Office 365 and Access 2016 Introductory 1st Edition Pratt TEST BANK

Crystal Reports 2008 OFT - 700

Ad Hoc Reporting: Filter Designer

COUNT Function. The COUNT function returns the number of rows in a query.

Access ComprehGnsiwG. Shelley Gaskin, Carolyn McLellan, and. Nancy Graviett. with Microsoft

Exploring Microsoft Office Access Chapter 2: Relational Databases and Multi-Table Queries

You can write a command to retrieve specified columns and all rows from a table, as illustrated

DATA Data and information are used in our daily life. Each type of data has its own importance that contribute toward useful information.

GRADE CENTER. Smart Views. Create Smart Views. You can create five types of smart views in the Grade Center:

Mysql Manual Order By Multiple Columns Example

MIS Cases: Decision Making With Application Software, Second Edition. Database Glossary

SQL functions fit into two broad categories: Data definition language Data manipulation language

THE UNIVERSITY OF AUCKLAND

Set theory is a branch of mathematics that studies sets. Sets are a collection of objects.

MySQL. A practical introduction to database design

Working with Attributes

Lab # 4 Hands-On. DDL and DML Advance SQL Statements Institute of Computer Science, University of Tartu, Estonia

Transcription:

Recapitulation Databases II: Microsoft Access CS111, 2016 A database is a collection of data that is systematically organized, so as to allow efficient addition, modification, removal and retrieval. A relational database is a collection of tables, where each row of the table is a record and each column is a field. Databases use foreign keys and primary keys to establish relationships between records on different tables. A database has referential integrity when all of the values in all foreign key fields point to the primary key of an existing record in the appropriate table (or are null). Today Microsoft Access - Creating a database and adding data Querying that database, i.e. retrieving specific information from the database If time allows, a brief look at report generation Microsoft: Access Creating a Database

Zoo Database I am going to build a database that a Zoo will use to keep track of the offspring of an endangered species. It is a deliberately simple database. Looking at these tables (and using some common sense about mothers and offspring) you should be able to figure out - the relationship between these tables what the primary and foreign keys are. Creating the database TABLE: Offspring ID Nickname Birthweight MotherID 1 Debra 44 2 2 Koko 52 3 3 Alf 50 3 4 Star 50 1... 1. Create the database 2. Create the tables, specifying details about each of the fields in each table 3. Populate the database i.e. add data to the database TABLE: Mothers ID Nickname 1 Kali 2 Chen 3 Beauty 4 Wind Creating a database... Creating a table New table button Templates Creating a new database

Creating a table Design view: create/view the fields in the table Datasheet view: create/view data in the table Design view Reassigning the primary key Datasheet view Right clicking on the field allows you to assign the primary key to something different than the default. Allows us to enter data into our table Some checks are done to ensure that we enter the correct type of data in each field (eg. no text in a number field)

Creating a relationship Creating a relationship Relationships view allows us to create relationships between fields in different tables Database Tools tab Relationships button Creating a relationship Creating relationships

Inserting data Inserting data Can we insert this record in the Enrolments table? Retrieving information from a DB Queries This won t work; StudentID s value ( 5 ) doesn t exist in the primary key ID Queries Queries allow you to retrieve certain fields from certain records from your database. There are two kinds of queries in Access: Query by example (QBE) Visual way of designing queries SQL (Structured Query Language): Uses commands to retrieve data from databases. Developed by IBM in the late 1970 s. * Access actually converts QBE queries into SQL before running them.

QBE queries Query By Example (QBE) We will ask the database these questions... A. B. C. D. E. F. What are the birth-weights of all of the offspring? What are the nicknames of all of the offspring of Beauty? In alphabetical order, what are the nicknames of all of the offspring of Beauty? In alphabetical order, what are the nicknames and birth-weights of all of Beauty s offspring? In alphabetical order, what are the nicknames of and birth-weights of all of Beauty s offspring that have a birth-weight of over 51 kilos? What is the average birthweight of all of Bea s offspring? QBE queries QBE queries Run button QBE grid Choosing fields Adding criteria to the field Query results

QBE queries - sorting Results from QBE queries can be sorted in ascending and descending order QBE queries A Totals QBE query allows us to group data using functions such as Min, Max, Avg, Sum etc. Totals button QBE queries QBE Exercise Complete this QBE grid so that it will return the first names, surname and grade (in that order) of all students who have received an A+. Sort the results by surname in alphabetical order

QBE Exercise Answer SQL introduction Complete this QBE grid so that it will return the first names, surname and grade (in that order) of all students who have received an A+. Sort the results by surname in alphabetical order Structured Query Language (SQL) was developed by IBM in the 1970s and is commonly used today QBE queries SQL queries It uses text commands to perform operations on databases, such as inserting and removing records and running queries Four clauses that can be part of a simple SQL query: SELECT FROM WHERE ORDER BY We will now together develop an SQL query that returns the first names, surname, and grade (in that order) of all students who have received an A+, with the results sorted by surname in alphabetical order.

SQL queries - SELECT SQL queries - FROM Selects fields from the tables that we want to display in our results table Specifies the table which holds the field(s) listed in the SELECT clause Syntax: SELECT [comma separated list] Syntax FROM [comma separated list] SELECT [First Names], Surname, Grade SELECT [First Names], Surname, Grade FROM Students Note the square brackets around First Names needed because of the space We will now together develop an SQL query that returns the first names, surname, and grade (in that order) of all students who have received an A+, with the results sorted by surname in alphabetical order. We will now together develop an SQL query that returns the first names, surname, and grade (in that order) of all students who have received an A+, with the results sorted by surname in alphabetical order. SQL queries - WHERE SQL queries - WHERE (example) Optional; used to provide criteria that limit the records displayed in the results table Comparisons (=, >, <, <=, >=, <>) e.g., WHERE [Land Area] < 50000 Syntax WHERE [criteria], [criteria], BETWEEN AND e.g., WHERE Price BETWEEN 10 AND 20 There are a range of criteria we can use LIKE (some pattern) e.g., WHERE [City] LIKE San *' AND, NOT, OR (combined with any of above) e.g., WHERE Country = New Zealand' AND City = Auckland' IS NULL, IS NOT NULL e.g., WHERE [Postal Code] IS NOT NULL SELECT [First Names], Surname, Grade FROM Students WHERE Grade = A+ We will now together develop an SQL query that returns the first names, surname, and grade (in that order) of all students who have received an A+, with the results sorted by surname in alphabetical order.

SQL queries ORDER BY SQL queries Optional; allows us to sort our data in ascending or descending order You need to ensure that you put a semi-colon on the last clause of your SQL query: Syntax: ORDER BY [name of field] [ASC/DESC] SELECT [First Names], Surname, Grade FROM Students WHERE Grade = A+ ORDER BY Surname ASC SELECT [First Names], Surname, Grade FROM Students WHERE Grade = A+ ORDER BY Surname ASC; We will now together develop an SQL query that returns the first names, surname, and grade (in that order) of all students who have received an A+, with the results sorted by surname in alphabetical order. SQL queries We run a SQL query in the same way that we run a QBE query Run button SQL exercise Write an SQL command that will (only) display the first names, surname and grade of students whose Total mark was greater than 70. Order the results table by ID number in ascending order

SQL exercise SELECT [First Names], Surname, Grade FROM Students WHERE Total > 70 ORDER BY ID ASC; Retrieving information from a DB Reports Reports The Report Wizard Reports allow you to present the contents of a table, query etc. in a nicely formatted table. Select the tables and fields you want to display in your report There are two ways of creating Reports: Report Tool (show entire table, some formatting control) Report Wizard (table/field selection, grouping, sorting)

The Report Wizard The Report Wizard You can group records in the report using particular fields You can sort records in the report by one or more fields The Report Wizard The Report Wizard You can set certain aspects of your report s formatting in the Wizard The finished report, ready for printing The final step involves giving the report a name and clicking on Finish You can continue to modify the report s formatting at this point

Thank you!