Presentation is loading. Please wait.

Presentation is loading. Please wait.

Test Review “Exam 1: Prof. McIntosh”

Similar presentations


Presentation on theme: "Test Review “Exam 1: Prof. McIntosh”"— Presentation transcript:

1 Test Review “Exam 1: Prof. McIntosh”
Computer Resource Center REACH 2016

2 On The Test Very little “application” questions
Topical Questions from Tutorial A and B Wiley Chapter 1 and Chapter 5 Case #1

3 On This Test Review Definitions of key terms Quick Content Review
How to… Create a query Create a table Create reports Create forms Import data Examples on how to create queries Quiz questions over content and terms

4 PowerPoint A copy of the PowerPoint can be found at:

5 Database Design Basic Terminology:
A table consists of data that is arrayed in rows and columns. A row of data is called a record. A column of data is called a field. Thus, a record is a set of related fields. The fields in a table should be related to one another in some way.

6 Basic Terminology Primary key field is a field in which each record has a unique value. e.g. The SSN Foreign key is the primary key of another table. e.g. suppose we need to link the employee table with the Hours worked table for payroll purposes. The Employee ID number (EIN) is the primary key of the employees table but the foreign key of the hours worked table. *Every foreign key must be associated with a primary key in another table. Primary field: so you will not find two ppl having the same SSN. So it should be sth unique for each record.

7 Basic Terminology A form is a database object that is created from an existing table to make the process of entering data more user-friendly A query is the database equivalent of a question that is posed about data in a table (or tables). Queries can be designed to search multiple tables but these tables should be connected by a join operation. For the query: suppose a manager wants to know the names of the employees who are older than 55 years old. A query can be designed to search the employees table for the information. Join operation: the join operation links tables on the values in a field that they have in common. The common field acts as a “hinge” for the joined tables; when the query is run, the query generator treats the joined tables as one large table.

8 Relationships In a one-to-one relationship, one instance of the first entity is related to just one instance of the second entity In a one-to-many relationship, one instance of the first entity is related to many instances of the second entity, but each instance of the second entity is related to only one instance of the first entity In a many-to-many relationship, one instance of the second entity is related to many instances of the second entity, and one instance of the second entity is related to many instances of the first

9 Relationships (Examples)
You have a specific driver license # that matches only to you *One to One 1 Employer has many Employees; 1 Guitar has many Guitar Strings;1 Car has many Seats *One to Many A book has more than one author, and each author writes many books. *Many to Many

10 Database Design Database design concepts:
Entities an entity is a tangible thing or an event. It is a person, place, thing or concept about which data can be collected. Consider the following examples: The database of a video store would have one entity named video and another named customer (These are physical entities). Organizations incur expenses from paying hourly employees and purchasing materials from suppliers. Hours worked and purchases are event entities in the database of most organizations. The library lends books for free. If you were to think of checking out a book as a sales transaction for zero revenue, how would you handle the revenue generating event? The event entity here is the number of checkouts. Sometimes it is hard to tell the difference between an attribute and an entity, but one good way to ask whether more than one attribute is possible for each entity. If more than one instance is possible, but you don’t know the number in advance, you are working with an entity.

11 Database Design Attributes- a characteristic of an entity. These attributes become the table’s field. E.g. what are the attributes for the entity “Customer”? Customer ID, First name, Surname, Date of Birth, Address and Phone no. What are the attributes for the entity “Fashion Model”? Name, Height, Weight, Dress size, Hair color and Eye color.

12 Database Design Rules Rule 1: You do not need a table for the business
The database represents the entire business. Thus in the practice example* The library is not an entity. *practice problem at the end of tutorial A. Rule 2: Identify the entities in the business description In our example the entities are Members, employees and books.

13 Database design rules Rule 3: Look for relationships among the entities look for relationships between entities; one-to-many and many-to-many. In our example: one-to-many: a member can check out more than one book. Rule 4: Look for attributes of each entity and designate a primary key. Attributes of members: name, DOB, phone no., address, member ID card number …etc. Employees: name, # of hours worked, job title,…etc. Books: name, authors, type, status, member ID card number…etc. Primary Key Foreign key

14 Database Design Rules Rule 5: Avoid data redundancy
you should not include extra (redundant) fields in a table. Redundant fields take up extra disk space and lead to data entry errors because the same value must be entered in multiple tables. Rule 6: Do not include a field if it can be calculated from other fields A calculated field is made using the query generator as we will see later. ** You should realize the importance of accuracy, case sensitivity…etc in designing databases.

15 Metadata & Hierarchy of Data
Metadata: Data about data. Metadata describes how and when and by whom a particular set of data was collected, and how the data is formatted. A text document's metadata may contain information about how long the document is, who the author is, when the document was written, and a short summary of the document. Hierarchy of Data: refers to the systematic organization of data, often in a hierarchical form. Data organization involves fields, records, files and so on.

16 Data Dictionary Data Dictionary: In database management systems, a file that defines the basic organization of a database. A data dictionary contains a list of all files in the database, the number of records in each file, and the names and types of each field. Most database management systems keep the data dictionary hidden from users to prevent them from accidentally destroying its contents.

17 Types of Queries Update Query Delete Query
Designed to change data in records Often updates information in real time (think online purchases and updating the on-hand amount of that item) Begins as a “Select” query, then begins by clicking “update” Delete Query Deletes entire records from a table Works similar to update query (must start with select query)

18 Types of Queries Select Query Append Query
Queries that answer a question “Selects” relevant data from database records Helps you get just the data you need in a Datasheet view Append Query Adds a record to the end of the table Works by selecting records from one or more data sources and copying them to an existing table

19 Use Update or Delete? Use a delete query
Type of query When to use it Results Use a delete query To remove entire records (rows) from a table or from two related tables simultaneously. Delete queries remove all the data in each field, including the key value that makes a record unique Use an update query To delete individual field values from a table. Makes it easier to delete values by updating the existing values to either a null value (that is, no data) or a zero-length string (a pair of double quotation marks with no space between them).

20 Creating Queries Using Calculated Fields in Queries:
E.g. suppose we have the following table. if you have an existing field containing the number of boxes of Girl Scout cookies sold, you may want to see how much money was collected for each cookie sale.  In this example, the boxes sold for $3.95 each. Prof Mcintosh is going to give you scenarios from which you will decide what type of query you want to create. So he will not ask you to build totals query or update query, you have to decide from the scenario.

21 Using Calculated Fields in Queries
In this case we will create a calculated field in a query. Create tab Query design Don’t Forget the Colon. Also the field name must be enclosed in square brackets.

22 Using Calculated Fields in Queries
How to format the calculated field output? 1. select the output column by clicking the line above the calculated field expression. 2. the column darkens to indicate the selection. 3. Design tab  property sheet  format

23 Avoiding errors when making calculated fields
Do not enter the expression in the criteria cell. Enter it in the Field cell. Spell, capitalize, and space a field’s name exactly as you did in the table definition. Don’t use parentheses or curly braces instead of the square brackets.

24 “Relating” two or more tables by the join operation
Suppose you want to see the last names, employee IDs, wage rates, salary status, and citizenship only for US citizens and hourly workers. Problem: the data is spread across two tables. Solution: add both tables and pull down the five fields you need. Step 1: Create tab  Query design Step 2: Click one table name and hold down the ctrl button while choosing the other table name. Step 3: start pulling down the fields you need and add the criteria expressions.

25 “Relating” two or more tables by the join operation

26 “Relating” two or more tables by the join operation
you can use calculated fields using more than one table. Just follow the same steps and add the calculated field in the design view like what we did earlier.

27 Totals Queries Assume that you want to see two pieces of information for hourly workers: The average wage rate 110 percent of the average rate Step1: Create the first query, click the design tab  Totals button in the show/hide group. This will give us the average of the wage rate field. Note that: you should type the revised heading for the wage rate field, i.e. Average rate: wage rate. N.B. we need the average of this field. Also to get the hourly workers only, enter Criteria=No.

28 Totals Queries Now begin a new Query. But instead of basing it on a table, we will base it on the previous query. Design the new query and create a calculated field inside it.

29 Using the Date() function in Queries
Access has two important date function features: The built in Date() function which gives today’s date. Date arithmetic lets you subtract one date from another to obtain the difference-in number of days- between two calendar dates.

30 Using the Date() function in Queries
Suppose you want to give each employee a $1 bonus for each day the employee has worked. So, you need to calculate the number of days between the employee’s date of hire and the date the query is run. Date arithmetic

31 Using time arithmetic in Queries
Access allows you to subtract the values of time fields to get an elapsed time. In Access, subtracting one time from the other yields the decimal portion of a 24-hour day. E.g. if the employee worked 8 hours, the time arithmetic function yields That’s why we multiply by 24.

32 Update Queries Suppose you want to give all non-salaried workers a $0.5 pay raise. If you have 3 workers  change the wage rate data in the table. If you have 3000 workers  it would be much faster and more accurate to change the wage rate by using an update query that adds $0.5 to each non-salaried employee’s wage rate. All the queries that we worked are select queries because they select certain data from specific tables based on a given criterion. You can also create queries to update the original data in a database.

33 Update Queries First start by making a select query.
Then click the update button in the query type group.

34 Update Queries We will write the updated data in the Update to line in the QBE grid. We will update only the non-salaried workers by using a filter under the salaried field.

35 Update Queries When you run the query, the following warning message will appear. Click yes, and the records will be updated.

36 Delete Queries Delete queries work like the update queries.
E.g. Suppose your company is purchased by the state of Delaware. So you need to delete or “fire” all employees who are not exclusively Delaware residents. <>  not

37 Scenario You have a table of medicines. One of them is now banned. Create a query with the new requirements. So what is the type of this query? Delete Query

38 Parameter Queries Suppose you want to know how many hours a particular employee has worked. Run a select query. You will get a message to enter the employee ID. Enter your employee ID and you will get the desired information

39 Practice Queries (p.33  37) #2 Create a query that shows the last name, first name, date hired, and state for employees who live in Delaware or were hired after 12/31/99. The primary sort (ascending) is on last name, and the secondary sort (ascending) is on first name. The primary sort field must be to the left of the Secondary sort field in the query setup. N.B. you have 3 tables. Employee  Last Name, First Name, Employee ID, Street Address, City, State, Zip, Date Hired, Us Citizen. Wage Data  Employee ID, Wage Rate, Salaried. Hours Worked  Employee ID, Week #, Hours.

40 Use this table to solve the practice query.
Field Table Sort Show Criteria Or:

41 Answer to practice query #2
Field  Last Name First Name Date Hired State Table  Employee Employee Sort  Ascending Show Criteria  >#12/31/1999#  =“DE” Or:

42 Practice Queries #6 Create a parameter query that shows the hours employees have worked. Have the parameter query prompt for the week number. The output headings should be Last Name, First Name, Week #, and hours. This query is for non-salaried employees only. N.B. you have 3 tables. Employee  Last Name, First Name, Employee ID, Street Address, City, State, Zip, Date Hired, Us Citizen. Wage Data  Employee ID, Wage Rate, Salaried. Hours Worked  Employee ID, Week #, Hours. Field Table Sort Show Criteria Or:

43 Answer to practice query #6
Field  Last Name  First Name Week #   Hours  Salaried Table  Employee  Hours Worked  Wage Date Sort Show Criteria  [Enter Week #]  =No Or:

44 Creating tables Create tab  Table design (in the tables group)
Fill in the table’s fields. Choose a suitable data type for each field. For example text  Last Name Date/time  Date Hired Yes/No  US Citizen Change the lengths of the text fields from 255 to 30 spaces.

45 Creating tables We need to make the Employee ID a primary key: Select the Employee ID field then in the Table tools Design click Primary Key tab After you finish click the File tab  Save object as  then name your table Note that this is different from Save Database as which saves the whole database.

46 Creating Compound Primary Key
The two fields must be appear one after the other in the table definition screen (plan ahead for that format). Highlight one field, hold down the control key and highlight the next field. Go to table tools  design tab Primary Key

47 Adding records to a table
Double click the table’s name in the navigation pane at the left of the screen then start typing data directly into the cells. Enter your data one field value at a time. Each time you finish entering a value, press Enter to move the cursor to the next cell. After you enter the data in the last cell in a row, the cursor moves to the first cell in the next row and Access automatically saves the record No need to save through the File tab.

48 Creating Reports Create basic ungrouped report:
Select the table  create tab  report Database packages let you make attractive management reports from a table’s records or from a queries’ output. If you are making a report from a table, the access report generator looks up the data in the table and puts it into report format. If you are making a report from a query’s output, Access runs the query in the background (you do not control it or see it happen) and then puts the output in report format.

49 Creating Reports Create Grouped Report:
Design tab  Group and Sort button in the grouping and tools group. Click the Add group button then select the desired table (Employee ID)

50 Creating Reports To total the hours worked by each employee: select the Hours column heading. Then on the Design tab  totals button in the grouping and totals group  Sum Layout View

51 Creating Reports Design tab  Report view from the views group
Report view (final view)

52 Creating Forms First select the table or query you want to base the form on then select Create tab  form When you create a form within another form  this is called a subform The Subform is useful when the form is based on one or more tables.

53 Creating Forms Step 1: select the table  create  Form
Take the form into design view. Design tab  make sure that the use control wizard option is selected  click the subform/subreport button.

54 Creating Forms Select use existing tables and Queries  Next
Use your cursor to stretch out the box under your main menu. This dialog box will appear

55 Creating Forms Choose the required table from the list  Next  select choose from a list  Next  Finish.

56 Importing Data Open the Excel application and create a spreadsheet.
In the Access application: External data tab  Excel in the import and link group

57 Importing Data

58 Importing Data Choose the correct worksheet
Make sure to select the first row contains column headings box

59 Importing Data Choose the default settings for each field you are importing

60 Importing Data Choose an appropriate name for your table *you can change your table design from Design button

61 Quiz Questions (Database Concepts) The metadata for a database describes which of the following properties of a database? It defines the fields in the database tables It defines the structure of the database tables It defines the sizes and formats of the fields in the database tables It identifies the primary keys All of the answers provided are correct

62 (Database Concepts) Because it is relatively common and everyone has one, the date of birth is often used as a primary key in a database table for identifying employees within a corporation. True False (Database Concepts) What is the term for a collection of related records, such as the scores for all of the students in a given section of CIS300? Field Character Item Table Query

63 Scenario You have a table of medicines. One of them is now banned. Create a query with the new requirements. Fill in the Blank. This is a/an ____________ Query Delete

64 (Database Concepts) Which of the following is the smallest piece of data that can be stored within a database? (select at least one, but no more than two answers) bit byte character field record table

65 (Database Concepts) Which of the following terms is often used to refer to the columns shown in a database table? (select at least one, but no more than two answers) row data element metadata field record data type

66 (Database Concepts) A field within a database is defined as a single item of data that is common to all records and occurs as an individual _____ within a table. cell column row value entry

67 (Microsoft Access) The Report Wizard is an easy to use feature in Access that guides you through a series of questions and then generates a customized report based on the answers you provide. True False

68 (Microsoft Access) Which of the following types of fields is used to produce a value from an expression or function? Calculated AutoNumber OLE Object Indexed Number

69 (Microsoft Access) Which of the following objects provides a simple approach for less-experienced users to extract information from a database? (select at least one, but no more than two answers) Forms Macros Modules Queries Reports Tables

70 While a database itself is a collection of several related files, the program used to build databases, populate them with data, and manipulate the data is called a(n) _DBMS – Database Management System. There are two overall approaches to maintaining data: the traditional file approach—which has no mechanism for tagging, retrieving, and manipulating data—and the ____, which does have this mechanism. Database Approach Data Approach Datafile Approach Indexed file approach

71 A ________ is a unit of information in a ________
A. record, data source B. data source, field C. record, field D. field, record

72 What do you call a primary key field included in another table?
A. Parent key B. Child key C. Foreign key D. Index


Download ppt "Test Review “Exam 1: Prof. McIntosh”"

Similar presentations


Ads by Google