Download presentation
Presentation is loading. Please wait.
1
Introduction to Databases with Access 2010
Instructor: Aarthi Natarajan April 26th, 2017 Based on slides by Robert Grauer, Keith Mast, Mary Anne Poatsy COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
2
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
Objectives What are databases, and how do they differ from Excel tables, or table-structured spreadsheets? Relational databases Keys, tables, foreign keys Navigate among objects in Access database Practice good database file management Back up, compact, and repair Access files Create filters Sort table data on one or more fields Know when to use Access or Excel to manage data COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
3
What is data? Data – facts that can be recorded and have implicit meaning (Elmasri & Navathe) Today data is being generated at an exponential rate Financial market data, posts to social media sites, growing logs of web transactions, computation physics…BIG Data Rate at which data is generated (rapid, exponential growth) Most Internet sites that ask you to input data use a database. Whether you’re using Google, Ebay, etc., you’re interacting with a database that is storing information about you and your purchases. why do you think it is useful for companies to have databases? Analytics! Rate at which data flows from different sources Diversity in data types – structured data (financial market data), semi-structured (XML, web logs, ), unstructured (audio, video streams) COMP1000 © UNSW
4
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
What is a database? Data by itself is not very useful. Give a context to data to transform data into information e.g., the numbers 45,55,67 do not mean much, but given a context such as these are the marks of students in COMP 1000, this is now information A database is collection of related data, which is organised such it can be easily accessed to produce useful information, can be managed and updated. Databases are everywhere… The Internet uses databases extensively. Every time you are asked to input data, you’re accessing a database e.g., Google, Ebay, Amazon, Book Depository, Medicare, Tax Office, credit card, debit card, iTunes shop, Facebook, Twitter, WebCMS, UNSW Library card, … Every time you use a loyalty card, you're inputting information about your buying habits into the database of the company in question. DATA -> INFORMATION -> DECISION Most Internet sites that ask you to input data use a database. Whether you’re using Google, Ebay, etc., you’re interacting with a database that is storing information about you and your purchases. why do you think it is useful for companies to have databases? Analytics! A database is a means of storing information in such a way that information can be retrieved from it. COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
5
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
Database concepts A database is a coherent collection of related data A Database Management System (DBMS) is an application or collection of programs that allows users to create and maintain a database A database and DBMS are collectively referred to as a Database System A Relational Database Management System (RDBMS) is a special type of DBMS that: Stores data as tables Allows the user to create relationships between tables Applications access the database through the DBMS by: Defining queries that causes data to be retrieved Through transactions that cause some data to be written or deleted from the database Why is it a good idea to create relations? Access is known as a Relational Database Management System (RDBMS). Using an RDBMS, you can manage groups of tables and create rules (the relationships) between the tables. When relational databases are designed properly, users can easily combine data from multiple tables to create queries, forms, and reports. Good database design is based on grouping like data into tables. The process of grouping data into properly designed tables is called normalization. It takes some time to learn how to do this effectively, but it’s well worth the time and effort. COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
6
More database concepts
A data model describes how the data is structured in the database A database schema adheres to a data model and provides a logical view of the database, defining how the data is organised and the relationships between them and is typically set up at the beginning A database instance is the state of the database at a particular instance of time Why is it a good idea to create relations? Access is known as a Relational Database Management System (RDBMS). Using an RDBMS, you can manage groups of tables and create rules (the relationships) between the tables. When relational databases are designed properly, users can easily combine data from multiple tables to create queries, forms, and reports. Good database design is based on grouping like data into tables. The process of grouping data into properly designed tables is called normalization. It takes some time to learn how to do this effectively, but it’s well worth the time and effort. COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
7
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
Data Models There are several types of data models Relational model a data structure where data is stored as a set of records known as tables a table consists of rows of information (also called a tuple) each row contains fields known as columns Document model data is stored in a hierarchical fashion e.g., XML Object-oriented model a data structure where data is stored as a collection of objects Object-Relational model a hybrid model that combines the relational and the object-oriented database models Why is it a good idea to create relations? Access is known as a Relational Database Management System (RDBMS). Using an RDBMS, you can manage groups of tables and create rules (the relationships) between the tables. When relational databases are designed properly, users can easily combine data from multiple tables to create queries, forms, and reports. Good database design is based on grouping like data into tables. The process of grouping data into properly designed tables is called normalization. It takes some time to learn how to do this effectively, but it’s well worth the time and effort. COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
8
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
Creating a database Choose a data model for the database Set up the structure of the database by defining a database schema for the database (e.g., for a relational data model, define the tables, rows and columns or field names and types of fields, constraints and relationships) Create the initial state of the data by loading data into the database After this, typically schema doesn’t change much, but data changes rapidly as new data is loaded or existing data is updated Why is it a good idea to create relations? Access is known as a Relational Database Management System (RDBMS). Using an RDBMS, you can manage groups of tables and create rules (the relationships) between the tables. When relational databases are designed properly, users can easily combine data from multiple tables to create queries, forms, and reports. Good database design is based on grouping like data into tables. The process of grouping data into properly designed tables is called normalization. It takes some time to learn how to do this effectively, but it’s well worth the time and effort. COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
9
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
Microsoft Access An application in Microsoft Office that is used to store and maintain data in a database Access is a RDBMS, using which you can: Create a database Create and edit tables in the database Create relationships between tables Build forms and reports that use these tables) Objects are the components that make a database function. The four most commonly used object types include tables, queries, forms and reports. Tables are the foundation of a database—a collection of related records. Queries are used to extract information from data. Data is the raw material; whereas information is the meaningful output. Forms allow users to enter information into tables. Reports are used to produce meaningful output from related tables or queries. Decisions are made from information produced by queries and reports, rather than the raw data found in tables. Two less commonly use object types are macros and modules. - Use example in access to show these things COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
10
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
Objects Objects – The main components in Microsoft Access RDBMS that are created and used to make the database function Four most commonly used object types Tables (data) Queries (extract information from data) Forms (enter data into tables) Reports (meaningful output) Two less commonly used object types Macros Modules Objects are the components that make a database function. The four most commonly used object types include tables, queries, forms and reports. Tables are the foundation of a database—a collection of related records. Queries are used to extract information from data. Data is the raw material; whereas information is the meaningful output. Forms allow users to enter information into tables. Reports are used to produce meaningful output from related tables or queries. Decisions are made from information produced by queries and reports, rather than the raw data found in tables. Two less commonly use object types are macros and modules. - Use example in access to show these things COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
11
Navigating Access Interface
Navigation Pane Organizes and lists the database objects in an Access database. Objects can be tables, queries, forms, reports, macros or modules Access Ribbon Contains the icons that enable you to perform functions to maintain your database First explain two main components of interface Open example a01h1traders.accdb and show Navigation pane Access ribbon Students should not be afraid of hiding/showing these components COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
12
Working with Table Views
Access provides two different views to view a table Datasheet View : A grid containing rows and columns similar to Excel and allows user to add, edit, delete records in a table Design View : allows user to create tables, add/delete fields, modify field data types and associated properties Data types define the type of data stored in a field such as text, number, currency, etc., e.g, to store the salary of an employee, create a field called “salary” and select the data type as currency Field properties define additional characteristics of fields e.g., pay rate to be >= $25 (defined using a validation rule) Datasheet View allows the user to add, edit, and delete records within a table. Design View allows the user to create tables, add and delete fields, and modify field properties. Fields can be assigned data types, such as text (the default), number, currency, etc. Field properties show the characteristics of the fields in more detail. COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
13
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
Design View Customers table in design view. Field names along left side. Each field has a Data Type. In this figure, the Customers table is displayed in design view. Notice Field Names are along the left side with each field having its own data type. Below the list of field names, you can change attributes of individual fields in the Properties window for each field selected. - Use example to explain field properties, etc. e.g. create a new field date of birth COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
14
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
Datasheet View Customers table in datasheet view. Field names along top. Data for first 27 records below. Here, the Customers table is displayed in the datasheet view. Notice that the Field Names are along the top. This is different from Excel where you see the column indicators along the top. Here, the database designer (the user) has created the field names to be used in this particular table. You can see the data within the table or select an individual record (row) for one particular entity within the table. COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
15
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
Tables Objects Tables Fields (Columns) Records (Rows) School Database Student Table Course Table S-ID S-FN S-LN C-ID C-Name S01 Bob Woods C01 Intro to Microcomputer Applications S02 Ted Trees C02 Computer Applications for Business S03 Carol Rose C03 Introduction to Computer Science S04 Alice Lilies C04 Introduction to Programming Start explaining example on the slide: Objects are the main components that are created and used to make the database function. Tables include data and are made up of records and fields about one type of entity. Examples of an entity would be a student, DVD, CD, or a piece of furniture. Records represent a complete set of all of the data elements (fields) about one particular entity. Examples of entities include a person, a place, an event, or a concept. Fields are the smallest pieces of data found in a table. Examples of fields include an individual person’s first name, last name, and middle initial. So, a database consists of one or more tables to store data, one or more forms to enter data into the tables, and one or more reports output the table data as meaningful information. COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
16
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
Tables in More Detail Records (one per line) Field Names ISBN Number Title Author Year List Price Publisher Exploring PowerPoint Grauer/Barber $ Prentice Hall Exploring Access Patel/Rao $ Prentice Hall Exploring Excel Flanagan $ Addison Wesley Exploring Word Cornell/Arnol $ Prentice Hall Introduction to Win95 Shepherd $ Addison Wesley Data is stored in a database in the form of tables, a collection of related records Each row represents a record. We can add, remove and alter records. A record is a complete set of all data elements (fields) about one person, place or concept e.g., first name, last name, address of a student Some times, records are also known as tuples. Each column represents a field. A field is the smallest data element contained in a table A field stores a specific type of data, i.e. number or character string or dollar value The field (or combination of fields) that is unique for each record is also known as primary key COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall. ENGG1811: Databases 16
17
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
Primary Keys A primary key is a field (or combination of fields) that is used to uniquely identify records. The Autonumber data type is often used to create unique values by automatically incrementing the value each time a new record is created. An example of a primary key would be a student’s ID number or a driver’s license number. Tables contain the raw data, but forms are objects that enable the user to enter, modify, or delete table data in a more user-friendly view. A primary key is a field (or combination of fields) that is used to uniquely identify records. The Autonumber data type is often used to create unique values by automatically incrementing the value each time a new record is created. An example of a primary key would be a student’s ID number or a driver’s license number. COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
18
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
Query A query is an Access object that allows a user to ask questions about the data in the tables and the answer is shown in the query results A query displays records that meet a certain criterion A criterion is a number, text phrase or an expression that allows records to be searched and filtered based on their field values e.g., the following criteria lists all records where Publisher = “Prentice Hall” , and Year > = 1996 New records can be added or records can be modified based on a search criteria. For example, the following adds $10 to all the books published in 1997 ISBN Number Title Author Year List Price Publisher Exploring PowerPoint Grauer/Barber $ Prentice Hall Exploring Word Cornell/Arnol $ Prentice Hall - Search query and update query ISBN Number Title Author Year List Price Publisher Exploring PowerPoint Grauer/Barber $ Prentice Hall Exploring Access Patel/Rao $ Prentice Hall Exploring Excel Flanagan $ Addison Wesley Exploring Word Cornell/Arnol $ Prentice Hall Introduction to Win95 Shepherd $ Addison Wesley COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall. ENGG1811: Databases 18
19
Working in Storage and Memory
Access works primarily from storage (hard-disk), unlike other MS Office applications such as Word, Excel and PowerPoint When you change the content of a field (e.g., phone number), Access saves the change as you soon shift focus to another record Changes to the design of a table, query, report or form must be saved Multiple users can work on an Access database simultaneously as long as they are not working on the same record. One person can be adding records to the Employees table, while another queries the table. Objects are the components that make a database function. The four most commonly used object types include tables, queries, forms and reports. Tables are the foundation of a database—a collection of related records. Queries are used to extract information from data. Data is the raw material; whereas information is the meaningful output. Forms allow users to enter information into tables. Reports are used to produce meaningful output from related tables or queries. Decisions are made from information produced by queries and reports, rather than the raw data found in tables. Two less commonly use object types are macros and modules. - Use example in access to show these things COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
20
Tips on Database Management
Database files should be named using meaningful names Database files should be stored in meaningful folders and subfolders Back up your files! Here are some tips to help manage your database. Access database files should be named with meaningful names—something that is meaningful to the content in the database. For example, if you are creating an inventory database for your household belongings, a name like “Household Inventory” would match the database content. Access files should be stored in meaningful folders and subfolders, so they can easily be located and accessed. Access works best on a local drive or a network drive because those drives provide the quickest access speeds to support the software. Above all, no matter what type of file you’re working with, backing up is paramount to maintaining the safety of your files. Backup creates a duplicate copy of the database. COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
21
Compacting & Repairing a Database (1)
Access databases increase in size over time Compacting Avoids loss of data Recovers unclaimed space Defragments fragmented databases Repairs corrupt databases Should compact your database daily Does every one know what defragmentation is? Because databases are the lifeblood of any organization, Access provides two utilities to help protect data within a database. These two utilities are: Backup and Compact and Repair. Compact and Repair reduces the size of the database. As data is entered, queries created, reports created and run, objects created and deleted and indexes added, Access databases tend to increase in size over time. This growth increases storage requirements and can impact database performance. By compacting databases regularly, they become less likely to become corrupt, which can cause a loss of data. When the Compact and Repair utility is run, it creates a copy of the database in the background, copying all of the objects from the original database into the new one. As it copies the objects into the new file, Access will remove temporary objects and unclaimed space due to deleted objects, resulting in a smaller database file. Compact and Repair will also defragment a fragmented database file, if needed. When the utility is finished copying the data, it deletes the original file and renames the new one with the same name as the original. If the database file is corrupt, the utility will also repair the corrupt database and, in most cases, only a small amount of data (usually just the last record modified) will be lost during the repair process. As a result, you should compact your database every day. COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
22
Compacting & Repairing a Database (2)
Compact & Repair option File -> Compact and Repair COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
23
Backing Up a Database (1)
Backups are critical to a database Access provides a default file name, including the original file name and adds on the current date Default extension for Access databases is accdb As backups are so critical for anyone storing a database, Access makes the process very simple. To back up files, click the File tab, then click Share from the list of options. From this list of options, click on Back Up database and the Save As dialog box will open. Here, you can designate the folder location and the file name for the backup copy of the database. Access provides a default file name that is the original file name followed by the current date. The default database extension is accdb. COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
24
Backing-up Your Database (2)
- File -> Save & Publish -> Back up database (double click on back up database) - Note that you are still working on the original database (cf. Save As) This figure shows the Backstage of the Share option off of the File Tab. This includes the Back Up Database option. You’ll first click on the File tab, which reveals the Backstage view. Then click on Compact & Repair Database, but before running this feature, close any open objects in the database. Then Click the File tab again, click Share, and then click Back Up Database. The Save As dialog box opens, verify the Save in folder is correct before saving. The backup utility assigns a default name by adding a date to your file name. Back Up Database option COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
25
Demonstration 1 – Open and Edit
Start Access, open a01h1traders.accdb and save a copy as a01h1traders_demo Click Enable Content Click Tables group in Navigation pane if necessary Double-click Employees table to open it Click Last Name field in row 4 (Peacock), double-click, replace with another name. Press Tab. Change name. Note pencil icon at left (means changed, not saved). Click in row 3. Pencil symbol vanishes – change saved. Experiment with changing and undoing. Click Close (x at top right) or right-click Employees tab and click Close. File -> Save Database As Goal: modify a Name in Table Employee (editing and automatic saving), undo within update and after Things are saved automatically as soon as you click on another row or go to another row with tab You can undo but only once! COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
26
Demo 2 – use Access form, add records
Click Tables group to collapse it, click Forms group to expand it. Double-click Products form to open it. Move between records using navigation buttons, bottom of window. Click Home / Find / Find. Type "Grandma" in Find What box, click Match arrow, select Any Part of Field. Click Find Next. Close Find dialogue box. Click New Blank Record on navigation bar. Enter BillW's Pecan Pie / Grandma Kelly's Homestead (click arrow) / Confections (click arrow) / 1 / / 18 / 50 / 20 / No (check box not checked). (Product ID automatically assigned.) Click in this record. Click File / Print / Print Preview. Click Last Page in navigation bar, then Previous, to view record just entered. Click Close Print Preview. Close Products form. Use Form Products Use of navigation button Find a record Find should find Grandma's Boysenberry Spread Create a new record using navigation bar Checking with File -> Print -> Print Preview COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
27
Demo 3 – table/ form connection, delete record
Click Forms group to collapse it, click Tables group to expand it. Double-click Products table to open it. Click Last Record in navigation bar. Navigate to 5th record, Chef Anton's Gumbo Mix Click Home / Find / Find. Type "Grandma" in Find What box, click Match arrow, select Any Part of Field. Click Find Next. Scroll right to Discontinued field. Click row selector box for 5th record. (Highlights with gold border.) Click Delete in Records group. Read error message. Click OK. Navigate to last record. Click row selector box. Click Delete. Read warning message. Click No. Goal: Check related info in Table and form Use of navigation button Use Find (Grandma) to find our previously inserted record Tried to delete discontinued product (Record 5) Cant delete because of related order Delete the record we just created (last one) Can't delete record 5 because the table Order Details has related records. None in stock and product discontinued, but can't be deleted while there are orders for it in the system. I can delete the record I just created It may be useful to go to Database Tools Relationships to see the relations between products and order details COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
28
Demo 4 – Compact & Repair, Backup database
Click File tab. Click Compact & Repair Database Defragments and eliminates waste space. Click File / Save & Publish. Double-click Back Up Database. You do not want to lose your data if the original becomes corrupted. Click Save to accept default backup name with today's date. COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
29
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
Filters A filter displays a subset of records based on specified criteria Will always display the entire record selected based on criteria selected All data extracted must be contained within a single table Hides unwanted records i.e., records that do not match the selection criteria, but does not delete them A filter displays a subset of records based on specified criteria. Filters allow you to analyze information very quickly, but a filter only works when all of the information needed is contained in a single table. Filters will always return the entire record, whether you need all of its data or not. They only display records that meet the criteria. When the filter is cleared, all of the records in the table will be displayed. COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
30
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
Types of Filters Filter by Selection Filter by Form Two types of Filters are discussed: Filter by Selection Filter by Form Filter by Selection selects only the records that match preselected single criteria. Filter by Form offers a more versatile way to select a subset of records, including the use of comparison operators. COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
31
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
Filter by Selection Displays only records that match selected criteria To implement a Filter by Selection Click in any cell field that contains the criterion on which you want to filter Click Filter by Selection in the Sort & Filter group Select Equals “criterion” from the list of options Only the records that match the selected criterion will be displayed – 'find records like this one' Use order details as an example Filter by Queso Cabrales Use Toggle filter do apply and un-apply filter Use filter Clear filter to completely remove filter Filter by selection only looks at value of current field If you save the changes, the filter is also saved ____________________ Filter by Selection displays only records that match selected criteria. To implement a Filter by Selection: Click in any cell field that contains the value on which you want to filter. Click Filter by Selection in the Sort & Filter group. Select Equals “criterion” from the list of options. Filter by Selection will display only the records that match the selected criteria. This type requires the user to specify criteria that are equal to an existing value. COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
32
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
Filter by Form Displays table records based on multiple criteria. Allows the use of AND and OR conditions Allows the use of comparison operators Comparison operators include: Filter by Form: Order details -> (Home) -> Advanced -> Filter by form select product queso cabrales Qantity >10 -> click toggle filter (apply filter) Advantages of the Filter by Form include: 1. Displays table records based on multiple criteria. 2. Allows the user to apply AND and OR conditions. 3. Allows the user to use a comparison operator. Comparison operators evaluate the relationship between two quantities and determine which one is greater than the other. Symbols for the comparison operators are included in the table. An example of using a comparison operator would be to select students with a GPA greater than 3.0. Greater than > Less than < Greater than or equal to >= Less than or equal to <= COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
33
Filter using ANDs and ORs
ANDs restrict selection criteria ORs expand selection criteria Show example of using OR Follow previous example OR -> Aniseed Syrup Quantity > 20 Explain that by default we are always doing AND operations You can expand your selection criteria by using the OR condition. Click on the OR tab at the bottom of the Filter by Form window. For example, you can use an OR to look for inventory greater than 30 OR prices less than $ This option will find inventory items that have more than 30 items and any prices less than $20.00, even though the number of inventory items may not be greater than 30. You can restrict your selection criteria by using the AND condition. Click on the AND tab at the bottom of the Filter by Form window. For example, you can use an AND condition to look for inventory greater than 30 AND prices less than $ This option will find all inventory items that have both more than 30 items and only prices with less than $20.00. COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
34
Filtering & Sorting Demo 1
Open a01h1traders_demo again Open Customers table, go to record 4, replace Contact Name field with COMP1000 Student Find & click City field in this record ("London") Click Sort&Filter>Selection>Equals "London" Click Sort&Filter>Toggle Filter Click Sort&Filter>Toggle Filter again Find & click a Contact Title of Sales Representative Click Sort&Filter>Selection>Contains "Sales Repre…" Check results, Toggle Filter, close Customers table (say No to "Save design changes?") Do not do this one COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
35
Filtering & Sorting Demo 2
Click Tables group in Navigation pane, then Queries group Locate & double-click Order Details Extended query Sort&Filter>Advanced>Filter by Form Click row 1 under First Name field, click First Name arrow Select our first name from the list. Ditto for Last Name. Find Extended Price field, click row 1, type "<50". Click Sort&Filter>Toggle Filter File>Print>Print Preview Click Print Preview>Close Print Preview. Close Order Details Extended query (don't Save changes) Filter on Queries work similarly Select steven buchanan Select extended price <50 COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
36
Filtering & Sorting Demo 3
Navigation pane>Queries group to close it Open Tables group, then double-click Customers Click a value in the Customer ID field, then Home>Sort&Filter>Descending. Find Country and City fields, click Country column heading Left click and hold Country column heading, note blue bar, drag till line between City and Region fields, release. Click a city, click Sort&Filter>Ascending Click a country, click Sort&Filter>Ascending Close Customers table (don't save changes) Sorting demo: Table Customers Sort ID descending Move Country field between City and Region Sort City ascending Sort Country descending _________ Sort a city then a country COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
37
Filtering & Sorting Demo 4
Open Products table Sort&Filter>Advanced>Filter by Form Supplier row 1, Supplier arrow, scroll, select "Grandma Kelly's Homestead" Click Or (bottom of window), Category row 1, Category arrow, Confections Click Sort&Filter>Toggle Filter Close Products, don't save changes File>Compact&Repair Database File>Save&Publish>double-click Back Up Database>Save This is an example of using OR (expand your selection criteria) Products Table Do first and AND (by default): Supplier “Grandma” and Category “Confections” Clear filter Then do and OR (using the bottom of window) Left-click = alt-click COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
38
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
When to use a Database Databases are ideal for maintaining data related to objects (e.g., student records, inventories, etc.) This data can be queried, sorted, etc. and the relationship between the objects and their attributes is maintained. While they can be used to perform numeric calculations, they are not usually optimised for this task. COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall. ENGG1811: Databases 38
39
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
Databases One important feature of a database is that the stored information is organised and structured in a particular way Usually databases try to allow for fast retrieval of information (via queries) even when they contain vast amounts of data It is important to pay careful attention to the design so as to structure the storage of data appropriately COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall. ENGG1811: Databases 39
40
Differences Between Spreadsheets and Databases
In a spreadsheet, changes to elements may affect other elements however the elements are not related in any other way. A database groups the attributes of an object together and treats them as “belonging” to that object. In a database, elements have a “type” (e.g., text, number, date, yes/no, etc.) COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall. ENGG1811: Databases 40
41
Problems that Databases Try to Deal With
Redundancy and inconsistency of data Different copies of information may exist (redundancy) and some attributes may differ (inconsistency) Access May need to allow/restrict access to different portions of data Multiple users accessing/modifying data at the same time Integrity Constraints on data that can be stored (e.g., only Gold status members entitled to a discount) Ask them to explain with examples Students and courses example COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall. ENGG1811: Databases 41
42
When to Use a Database Rather than a Spreadsheet?
Database stores information in a structured way as relations: attribute values of a single object Different attributes have a data type Spreadsheet doesn’t maintain information in this way (only formula dependencies) and has only a few data types Use DBMS when it is important to maintain attributes of objects as single entities, and relationships between objects Spreadsheet is normally useful for calculations and visualisation of information COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall. ENGG1811: Databases 42
43
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
Excel or Access? It is better to use Excel, if you: Are more comfortable with its ease of use Only need one worksheet to handle all of your data Have mostly numeric data Flat (non-relational) data Require subtotals and totals for a worksheet Want to use “what if” scenarios on data Need to create complex charts and/or graphs There are a lot of similarities between Access and Excel. They both store data. They can both create formulas to summarize data. They can both sort data and filter data. So, when do you use each one? Generally, when you have data better suited to two or more tables, Access is preferred. Access is also more appropriate when dealing with large amounts of data. - What if: What if the product price is now $100 more expensive. What is the total revenue? COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
44
Access or Excel? (continued)
It is better to use Access when you: Need multiple related tables to store data Have a large amount of data Need to connect to and retrieve data from external databases (such as Microsoft SQL Server) Need to group, sort, and total data based on criteria Need multiple users to have access to application simultaneously Need built-in tools to help organize data Ability to create relationships between tables - Remember though that two users may not write data to the same record at the same time—one can view and the other can write, but both users cannot write to the same record at the same time. - built-in tools such as relationships that allow you to maintain the integrity of the database COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
45
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
Summary Access works best for large amounts of data stored in multiple related tables using relationships between tables Access allows you to sort and filter data Access allows you to compact and repair and back up your data Practicing good database file management will improve the quality of your database In this chapter, you learned the distinction between data and information. Access stores data, but by manipulating the tables storing raw data, meaningful information can be displayed. Access works best for large amounts of data stored in multiple tables, using relationships between tables. Multiple users may need access to the database at the same time. Access also allows the user to sort and filter data to extract information quickly. An established routine of compacting and repairing and backing up your database will help to maintain the integrity of your data. Finally, practicing good database file management techniques will improve the quality of your database. Creating tables before entering sample data will produce a better database design and could help you avoid much time-consuming repairs on an ill-formed database design. COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
46
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
Quiz 1 Which sequence represents the hierarchy of database terms, from smallest to largest? Database, table, record, field Field, record, table, database Record, field, table, database Field, record, database, table b) fields live in records, which live in tables, which live in databases. COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
47
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
Quiz 2 You perform several edits in a table within an Access database. When should you execute the Save command? Immediately after you add, edit, or delete a record Each time you close a table or a query Once at the end of a session Records are saved automatically; the save command is not required. d) is correct: edits within a table are saved automatically Doesn't happen in Excel. Or Word. COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
48
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
Quiz 3 Which of the following is not true of an Access database? Every record in a table contains the same number of fields as every other record. Every table in a database contains the same number of records as every other table. Text, Number, Autonumber, and Currency are valid data types. Each table should contain a primary key; however, a primary key is not required. b) Tables can contain arbitrary numbers of records. COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
49
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
Quiz 4 You are looking at an Employees table in Datasheet view. You want the names sorted alphabetically by last name and then by first name-for example, Smith, Andrea is listed before Smith, William. To accomplish this, you must: First sort ascending on first name and then on last name. First sort descending on first name and then on last name. First sort ascending on last name and then on first name. First sort descending on last name and then on first name. a) ascending on first name then on last name COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
50
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
Quiz 5 Which of the following will be accepted as valid during data entry? Adding a record with a duplicate primary key Entering text into a numeric field Entering numbers into a text field Omitting an entry in a required field c) is OK – numbers are a kind of text COMP1000 © UNSW Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall.
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.