Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Database using Microsoft Access 2013 Part 7 November 19, 2014.

Similar presentations


Presentation on theme: "Introduction to Database using Microsoft Access 2013 Part 7 November 19, 2014."— Presentation transcript:

1 Introduction to Database using Microsoft Access 2013 Part 7 November 19, 2014

2 Types of Relationships

3 What is Relationship? (in Microsoft Access) In a relational database, relationships enable you to prevent redundant data. For example, if you are designing a database that will track information about books, you might have a table named "Titles" that stores information about each book, such as the book’s title, date of publication, and publisher. There is also information that you might want to store about the publisher, such as the publisher's telephone number, address, and ZIP Code/Postal Code. If you were to store all this information in the "Titles" table, the publisher’s telephone number would be duplicated for each title that the publisher prints.

4 A better solution is to store the publisher's information only one time, in a separate table that we will call "Publishers." You would then put a pointer in the "Titles" table that references an entry in the "Publishers" table. To make sure that you data stays synchronized, you can enforce referential integrity between tables. Referential integrity relationships help make sure that information in one table matches information in another. For example, each title in the "Titles" table must be associated with a specific publisher in the "Publishers" table. A title cannot be added to the database for a publisher that does not exist in the database. Logical relationships in a database enable you to efficiently query data and create reports.

5 Types of Relationships One to One Relationship

6 In a one-to-one relationship, a row in table A can have no more than one matching row in table B, and vice versa. A one-to-one relationship is created if both of the related columns are primary keys or have unique constraints. This kind of relationship is not common, because most information that is related in this manner would be in one table. You might use a one-to-one relationship to take the following actions: Divide a table with many columns. Isolate part of a table for security reasons. Store data that is short-lived and could be easily deleted by deleting the table. Store information that applies only to a subset of the main table. In Access, the primary key side of a one-to-one relationship is denoted by a key symbol. The foreign key side is also denoted by a key symbol.

7 Types of Relationships One to Many Relationships

8 A one-to-many relationship is the most common kind of relationship. In this kind of relationship, a row in table A can have many matching rows in table B. But a row in table B can have only one matching row in table A. For example, the "Publishers" and "Titles" tables have a one-to-many relationship. That is, each publisher produces many titles. But each title comes from only one publisher. A one-to-many relationship is created if only one of the related columns is a primary key or has a unique constraint. In the relationship window in Access, the primary key side of a one-to-many relationship is denoted by a number 1. The foreign key side of a relationship is denoted by an infinity symbol.

9 Types of Relationships Many to Many Relationships

10 In a many-to-many relationship, a row in table A can have many matching rows in table B, and vice versa. You create such a relationship by defining a third table that is called a junction table. The primary key of the junction table consists of the foreign keys from both table A and table B. For example, the "Authors" table and the "Titles" table have a many-to-many relationship that is defined by a one-to- many relationship from each of these tables to the "TitleAuthors" table. The primary key of the "TitleAuthors" table is the combination of the au_ID column (the "Authors" table’s primary key) and the title_ID column (the "Titles" table’s primary key).

11 How to Create One-to- One Relationship

12 Begin Click MS Access 2013 On the MS Access Screen Pane, select Blank Database Create a name that will reserve as your file for the database

13 In the screen pane, click blank desktop database

14 In the screen box, click the browse button to save in any file that you want Write your name in the box that you want to save your database Click create if done

15 In the MS Access Environment Right Click the “Table 1”.

16 Click Design View

17 Save first. Write your name inside the Table Name Box Click “OK” if done.

18 You are now in the Design View.

19 How to add fields in the design view Write first your Field Name.

20 Second, select from the data type that you want.

21 Third, is to write a short description based on your field name.

22 If you're done. Click the General Properties (Field) to emphasize your field.

23 Now you're sample will be like this. With the Field Properties.

24 Create another table also and repeat slides 12-23.

25 Now I created two tables on the screen.

26 Go to “DATABASE VIEW” and click “Relationships”

27 Click Relationships

28 The “Show Table has arrived. Click any of the Tables that you want to relate with.

29 I clicked “Relationship” and the overview is.

30 Just simply drag the “Item1” to “Item1”. It should be the same primary key. Same data type and same name like “Item1” and “Item1”. Then the message appears.

31 Click “Enforce Referential Integrity” Or if you want to click “Cascade Update Related Fields” and “Cascade Delete Related Records” And press the “Create Button”

32 Then the Relationship appears.

33 How to Create One-to- Many Relationship

34 Repeat Slide 12-23. Create another table and repeat slide 12-23.

35 Now I Created Three Tables.

36 In One-to-Many Relationship. A Primary Key must be related to a non-primary key. It should have the same data type, and the same name also. Drag the Name to its same Name also. The message appears Click Enforce Referential Integrity And click Create if done.

37 Then the relationship appears.

38 How to Create Many-to- Many Relationship

39 Repeat Slide 12-23. Create another table and repeat slide 12-23.

40 Repeat slide 33-36.

41 The relationship appears.

42 You can select the “Join Properties” that your output will be added to.

43 You can press the Create Button. If you want to have One to One Relationship.

44 Deleting Relationships RIGHT Click the Relationship Arrow. Then Click Delete.


Download ppt "Introduction to Database using Microsoft Access 2013 Part 7 November 19, 2014."

Similar presentations


Ads by Google