Office Management Tools II Ms Saima Gul.  When you create your tables, you should assign each table a primary key—one or more fields whose contents are.

Slides:



Advertisements
Similar presentations
© Paradigm Publishing, Inc Access 2010 Level 1 Unit 1Creating Tables and Queries Chapter 2Creating Relationships between Tables.
Advertisements

Access Manual 4 By Elham S.Khorasani Ismail Guneydas Dhawala Kovuri.
Microsoft Access.
AS ICT Building MS-Access Databases. Creating a Combo Box Drop Down List 1.When creating a Field requiring a Drop Down list in a Table, select the Lookup.
Microsoft Office 2007 Access Chapter 3 Maintaining a Database.
XP New Perspectives on Microsoft Access 2002 Tutorial 61 Microsoft Access 2002 Tutorial 6 – Creating Custom Reports.
Microsoft Office 2010 Access Chapter 1 Creating and Using a Database.
Access Lesson 2 Creating a Database
ISP 121 Access Normalization and Relationships. Normalization Say we’re operating a pet day-care and we need to keep information on our pets/customers.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 3 1 Microsoft Office Access 2003 Tutorial 3 – Querying a Database.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 2 1 Microsoft Office Access 2003 Tutorial 2 – Creating And Maintaining A.
SUNY Morrisville-Norwich Campus-Week 10 CITA 130 Advanced Computer Applications II Spring 2005 Prof. Tom Smith.
RELATIONSHIP  THE WAY TABLES ARE RELATED  A TABLE MUST PARTICIPATE IN AT LEAST ONE RELATIONSHIP  IN A BINARY RELATIONSHIP TWO ENTITIES PARTICIPATE 
Creating And Maintaining A Database. 2 Learn the guidelines for designing databases When designing a database, first try to think of all the fields of.
Querying a Database Microsoft Office Access 2003.
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Access Project 3 Maintaining a Database Using the Design and Update Features of Access.
Management Information Systems MS Access 2003 By: Mr. Imdadullah Lecturer, Department of M.I.S. College of Business Administration, KSU.
Chapter Extension 6 Using Microsoft Access © 2008 Pearson Prentice Hall, Experiencing MIS, David Kroenke.
Define Table Relationships—1 of 3 One of the most powerful features of a relational database management system, such as Access, is its ability to define.
Microsoft ® Office Access ® 2007 Training Build a database III: Build relationships for a new Access database ICT Staff Development presents:
WORKING WITH MACROS CHAPTER 10 WORKING WITH MACROS.
Chapter 3 Maintaining a Database
XP New Perspectives on Microsoft Access 2002 Tutorial 41 Microsoft Access 2002 Tutorial 4 – Creating Forms and Reports.
ACCESS CHAPTER 1. OBJECTIVES Tables Queries Forms Reports Primary and Foreign Keys Relationship.
Microsoft Access Lesson 3
1 Microsoft Access 2002 Tutorial 3 – Querying a Database.
Primary & Foreign Keys. PK & FK 1.Primary key is required 2.The PK must be unique 3.If the primary key from one table is related to a field in another.
Microsoft Access – Tutorial 3
Viewing Tip: While viewing this presentation in your browser, select Browse, Full Screen. Then, when you want to pause the show, Right Click and select.
XP Chapter 2 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Building The Database Chapter 2 “It is only the farmer.
® Microsoft Office 2013 Access Building a Database and Defining Table Relationships.
Microsoft Access 2003 Define some key Access terminology: Field – A single characteristic or attribute of a person, place, object, event, or idea. Record.
Management Information Systems MS Access MS Access is an application software that facilitates us to create Database Management Systems (DBMS)
Microsoft Access 2000 Presentation 2 Creating Databases Part I (Creating Tables)
XP New Perspectives on Microsoft Office Access 2003 Tutorial 9 1 Microsoft Office Access 2003 Tutorial 9 – Using Action Queries, and Defining Table Relationships.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. ACCESS 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 9 – Building Links,
XP New Perspectives on Microsoft Access 2002 Tutorial 21 Microsoft Access Tutorial 2 – Creating And Maintaining A Database.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 2 1 Microsoft Office Access 2003 Tutorial 2 – Creating And Maintaining A.
Relationships and Advanced Query Concepts Using Multiple Tables Please use speaker notes for additional information!
MS Access 2007 Management Information Systems 1. Overview 2  What is MS Access?  Access Terminology  Access Window  Database Window  Create New Database.
® Microsoft Office 2010 Building a Database and Defining Table Relationships.
McGraw-Hill/Irwin © 2008 The McGraw-Hill Companies, All Rights Reserved Plug-In T6: Basic Skills and Tools Using Access 2010 Business Driven Technology.
Microsoft Office 2007 Access Chapter 3 Maintaining a Database.
Office Management Tools II Ms Saima Gul. Office Management Tools II Ms Saima Gul.
Microsoft Access Intro Class 6 Relationships.
® Microsoft Office 2013 Access Creating a Database.
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 2 BACKNEXTEND 2-1 LINKS TO OBJECTIVES Creating Related Tables Creating Related Tables Determining.
Introduction to Database using Microsoft Access 2013 Part 7 November 19, 2014.
McGraw-Hill/Irwin © The McGraw-Hill Companies, All Rights Reserved TECHNOLOGY PLUG-IN T6 Basic Skills Using Access.
INFORMATION TECHNOLOGY DATABASE MANAGEMENT. Adding a new field 1Right click the table name and select design view 2Type the field information at the end.
You can sort Access data so you can view records in the order you want to view them, and you can filter data so you only see the records you want to see.
XP New Perspectives on Microsoft Office FrontPage 2003 Tutorial 7 1 Microsoft Office FrontPage 2003 Tutorial 8 – Integrating a Database with a FrontPage.
1 CHƯƠNG 4 Creating Relational Databases Understanding Table Relationships Example: This database tracks customers and their orders in two separate.
Pasewark & Pasewark Microsoft Office 2003: Introductory 1 INTRODUCTORY MICROSOFT ACCESS Lesson 4 – Finding and Ordering Data.
XP New Perspectives on Microsoft Access 2002 Tutorial 31 Microsoft Access 2002 Tutorial 3 – Querying a Database.
Work with Tables and Database Records Lesson 3. NAVIGATING AMONG RECORDS Access users who prefer using the keyboard to navigate records can press keys.
Key Applications Module Lesson 22 — Managing and Reporting Database Information Computer Literacy BASICS.
MSOffice Access Microsoft® Office 2010: Illustrated Introductory 1 Part 1 ® Database & Table.
Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall. 1 Skills for Success with Microsoft ® Office 2007 PowerPoint Lecture to Accompany.
XP Chapter 1 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Level 2 Objectives: Understanding and Creating Table.
Access Lesson 1 Understanding Access Fundamentals
Microsoft Office Access 2003
Tutorial 3 – Querying a Database
Microsoft Office Access 2003
Microsoft Office Access 2003
Relationships While we are on the subject of Relationships, let’s take a quick look at them.
Presentation transcript:

Office Management Tools II Ms Saima Gul

 When you create your tables, you should assign each table a primary key—one or more fields whose contents are unique to each record.  This key is a way to make sure that the table records contain only one unique value.  The capability to assign a single, unique value to each record makes the table “clean” and reliable. This is known as entity integrity in the world of database management.  By having a different primary key value in each record, you can tell two records (in this case, students) apart. This is important because you can easily have two individual students named Atif in your table.  The goal of setting primary keys is to create individual records in a table that will guarantee uniqueness. 2

 Primary keys guarantee uniqueness in a table, and you use the primary key field in one table to link to related records in another table.  The common link field in the other table (records that are associated with a record in the primary table) may not be (and usually isn’t) the primary key in the other table.  The common link field is a field or fields that hold the same type of data (matching the content of the field exactly) as in the primary key of the link table. This common link field, or combination of fields, is known as a foreign key field.  By matching the same values (from a primary key field in a record in the primary key table to the values in a specific field of one or more records in a foreign key table) in both tables, you can relate records between tables. 3

 Before you learn to create these relationships, it is important to understand them.  There are three types of relationships that you can set between two tables:  One-to-one  One-to-many  Many-to-many. 4

 When you physically join two tables (by connecting fields with like information), you create a relationship that Access recognizes.  The relationship that you specify between tables is important. It tells Access how to find and display information from fields in two or more tables. The program needs to know whether to look for only one record in a table or look for several records on the basis of the relationship. 5

 One-to-one (l:l)—An occurrence of [object] 'A' can relate to one and only one occurrence of [object] 'B,' and an occurrence of 'B' can relate to only one occurrence of 'A.'  One-to-many (l:N)—One occurrence of [object] 'A' can relate to one or many occurrences of [object] 'B,' but an occurrence of 'B' can relate to only one occurrence of 'A.’  Many-to-many (M:N)—An occurrence of [object] 'A' can relate to one or more occurrences of 'B,' while an occurrence of 'B' can relate to one or more occurrences of 'A.’ 6

Many-to-many One-to-one issues

 In addition to specifying relationships between tables in an Access database, you can also set up some rules that will help in maintaining a degree of accuracy, or Referential Integrity, between the tables.  For example, you would not want to delete a student record in your Student table if there are related program records in the Program table. If you did delete a student record without first deleting the student’s program record, you would have a system that had programs with students whose data do not exit. This type of problem could be catastrophic.  So a database system needs to have rules that specify certain conditions between tables — rules to enforce the integrity of information between the tables. These rules are known as referential integrity; they keep the relationships between tables intact in a relational database management system.  Referential integrity prohibits you from changing your data in ways that invalidate the links between tables. 8

 Referential integrity operates strictly on the basis of the tables’ key fields; it checks each time a key field, whether primary or foreign, is added, changed, or deleted.  If a change to a value in a key field creates an invalid relationship, it is said to violate referential integrity.  Tables can be set up so that referential integrity is enforced automatically.  When tables are linked, one table is usually called the parent and the other (the table it is linked to) is usually called the child. This is known as a parent-child relationship between tables.  Referential integrity guarantees that there will never be an orphan, a child record without a parent record. 9

 Access has a very powerful Relationships window. With it, you can add tables, use drag-and-drop methods to link tables, easily specify the type of link, and set any referential integrity between tables.  You begin creating relationships in the Database window. From this window, you can select Tools ➪ Relationships or click the Relationships button on the toolbar.  The main Relationships window appears, which lets you add tables and create links between them.  When first opened, the Relationships window is a blank surface. Tables are added to the window by using one of these methods:  Add the tables before entering the Relationships window from the Show Table dialog box that’s first displayed.  Click the Show Table button on the toolbar.  Click Relationships ➪ Show Table from the menu bar.  While in the Relationships window, click the right mouse button (which displays the shortcut menu) and select Show Table from the menu. 10

 To start the Relationships window and add the tables to the Relationships window, follow these steps: 1. Click the Relationships button on the toolbar. Access opens the Show Table dialog box. 2. Select all the tables by clicking the first table, holding Shift, and clicking last table name. Then click Add. 3. Click the Close button on the Show Table dialog box. Notice that Access has placed each table in the Relationships window. Each table is in its own box; the title of the box is the name of the table. Inside the table box are the names of the fields for each table. Currently, there are no relationships, or lines, between the tables. Now you are ready to set relationships between them. 12

 To create a relationship between two tables, select the common field in one table, drag it to the field in the table you want to relate it to, and drop it on the common field.  Follow these steps to create a relationship between the Program and Student tables: 1. Click the progId field of the Program table. 2. While holding down the mouse button, move the cursor to the Student table. Notice that Access displays a field-select icon (a small rectangular box with lines inside of it) as you hold and drag the progId field from the Program table. 3. Drag and drop the field-select icon to the pId field of the Student table. Access displays the Edit Relationships dialog box. 4. Click the Create button to create the relationship. Access closes the dialog box and places a join line between the Program and Student tables. 14

After you click Create button in Edit Relationships dialog box

 The Edit Relationships dialog box has several options for the relationship between the Program and Student tables.  The Edit Relationships dialog box tells you which table is the primary table for the relationship and whether referential integrity is enforced (a check box below the names of the related fields on the left side).  The dialog box also tells you the type of relationship (one-to-one or one-to-many—at the bottom of the dialog box) and lets you specify (after selecting Enforce Referential Integrity) whether cascading updates and deletes (automatically fix key changes or deletions in related records) between related tables are allowed. 17

 The top of the dialog box has two table names—Program on the left and Student on the right.  The Program table is considered the primary table for this relationship.  The dialog box shows the related fields for each table in a separate box immediately below the table names.  Make sure that the correct table name is in both boxes and that the correct field is specified (progId and pId). 18

 The right side of the Edit Relations window has four buttons—OK, Cancel, Join Type, and Create New... buttons. Pressing the OK button returns you to the Relationships window with any changes specified.  The Cancel button will cancel the current changes and also return you to the Relationships window.  The Create New... button will let you specify a new relation between two tables and fields.  The one button that you should also click after you first activate the Edit Relations dialog box is Join Type. This button will activate another window—the Join Properties dialog box.  This dialog box lets you decide if you want to see records in both tables, see all records in one table or the other, or see only those that are related.  For instance, to make sure that you have the correct join type between the Program and Program tables, follow these steps: 19

After you click Join Type button in Edit Relationships dialog box

1. Click the Join Type button to activate the Join Properties Dialog box. 2. Click the option that says “Include ALL records from ‘Program’ and only those records from ‘Student’ where the joined fields are equal.” (the second option on the authors system). 3. Click the OK button to return to the Edit Relationships Dialog box. 4. Click the OK button of the Edit Relationships dialog box to return to the Relationships window.  You have now specified that the relationship is from the Program table to the Student table—meaning that many students can be related to a single program.  The Relationships window should now show an arrow going from the Student table to the Program table. At this point, you are ready to set Referential Integrity between the two tables. 21

 After specifying the relationship, verifying the table and related fields, and specifying the type of join between the tables, you can set referential integrity between the tables by clicking the Enforce Referential Integrity check box below the table information.  If you choose not to enforce referential integrity, you can add new records, change key fields, or delete related records without worrying about referential integrity—thus making it possible to change critical fields without being warned or prevented from doing so.  With no integrity active, you can create tables that have orphans (student not enrolled in any program) or parents without children (program in which no student is enrolled).  With normal operations (such as data entry or changing information), referential integrity rules should be enforced. By setting this option, you can specify several additional options. 23

 Re-open the Edit Relationships dialog box for the relations between the Program and Student tables by double-clicking on the join line.  Clicking the check box in front of the option Enforce Referential Integrity activates the two Cascading choices (Update and Delete) in the dialog box and enforces Referential Integrity. 24

 If you specify Enforce Referential Integrity in the Edit Relationships dialog box, Access activates a check box option labeled Cascade Update Related Fields.  This option tells Access that a user can change the contents of a related field (the primary key field in the primary table)  When the user changes the contents of the primary key field in the primary table, Access verifies that the change is to a unique value (because there cannot be duplicate records in the primary table) and then goes through the related records in the many table and changes the foreign key value from the old value to the new value.  If this option is not selected, you cannot change the primary key value in the primary table that is used in a relationship with another table. 25

 Similarly, if you specify Enforce Referential Integrity in the Edit Relationships dialog box, Access activates the Cascade Delete Related Records check box.  By selecting this option, you tell Access that if a user attempts to delete a record in a primary table that has child records, first it must delete all the related child records and then delete the primary record.  If you do not specify this option, Access will not enable you to delete a record that has related records in another table. 26

 Now you can create relationships among the remaining tables. 27

28

29

30

 Create a junction table carrying key fields of the two tables to be related.  To be explained in class!

32