قواعد البيانات access foundation قواعد البيانات access foundation - تجارب الاعضاء - اسئلة وحلول [يمنع إضافة الإستفسارات]


عدد مرات النقر : 19,646
عدد  مرات الظهور : 34,977,468

إضافة رد
 
LinkBack أدوات الموضوع انواع عرض الموضوع
قديم 15-08-2019, 09:03 PM   #1


 رقم العضوية :  125738
 تاريخ التسجيل :  13-08-2019
 المشاركات :  123
 الدولة :  Mongolia
 الجـنـس :  ذكر
 عدد النقاط :  10
 قوة التقييم :  WileyRot is on a distinguished road
 اخر مواضيع » WileyRot
 تفاصيل مشاركات » WileyRot
 أوسمة و جوائز » WileyRot
 معلومات الاتصال بـ WileyRot

افتراضي Guide to table relationships


Guide to table relationships

Access for Office 365 Access 2019 Access 2016 Access 2013 Access 2010 Access 2007

One of the goals of good databa se design is to remove data redundancy (duplicate data). To achieve that goal, you divide your data into many subject-bas ed tables so that each fact is represented only once. You then provide Access with a way to bring the divided information back together — you do this by placing common fields in tables that are related. To do this step correctly, though, you have to understand the relationships between your tables, and then specify these relationships in your data .
In this article

Introduction
Types of table relationships
Why create table relationships?
Understanding referential integrity
View table relationships
Introduction

After you have created a table for each subject in your databa se, you have to give Access a way to bring that information back together again when needed. You do this by placing common fields in tables that are related, and by defining relationships between your tables. You can then create queries, forms, and reports that display information from several tables at once. For example, the form shown here includes information drawn from several tables:

1. Information in this form comes from the Customers table...
2. ...the Orders table...
3. ...the Products table...
4. ...and the Order Details table.
The customer name in the Bill To box is retrieved from the Customers table, the Order ID and the Order Date values come from the Orders table, the Product name comes from the Products table, and the Unit Price and Quantity values come from the Order Details table. These tables are linked to each other in a variety of ways to bring information from each into the form.
In the preceding example, the fields in the tables must be coordinated so that they show information about the same order. This coordination is accomplished by using table relationships. A table relationship works by matching data in key fields — often a field with the same name in both tables. In most cases, these matching fields are the primary key from one table, which provides a unique identifier for each record, and a foreign key in the other table. For example, employees can be associated with orders for which they are responsible by creating a table relationship between the EmployeeID fields in the Employees and the Orders tables.

1. EmployeeID appears in both tables — as a primary key ...
2. ... and as a foreign key.
Top of Page
Types of table relationships

There are three types of table relationships in Access.
  • A one-to-many relationship
    Let’s use an order tracking databa se that includes a Customers table and an Orders table as an example. A customer can place any number of orders. It follows that for any customer represented in the Customers table, there might be many orders represented in the Orders table. The relationship between the Customers table and the Orders table is a one-to-many relationship.
    To represent a one-to-many relationship in your data************ design, take the primary key on the "one" side of the relationship and add it as an additional field or fields to the table on the "many" side of the relationship. In this case, for example, you add a new field — the ID field from the Customers table — to the Orders table and name it Customer ID. Access can then use the Customer ID number in the Orders table to locate the correct customer for each order.
  • A many-to-many relationship
    Now let’s look at the relationship between a Products table and an Orders table. A single order can include more than one product. On the other hand, a single product can appear on many orders. Therefore, for each record in the Orders table, there can be many records in the Products table. In addition, for each record in the Products table, there can be many records in the Orders table. This relationship is called a many-to-many relationship. Note that to detect existing many-to-many relationships between your tables, it is important that you consider both sides of the relationship.
    To represent a many-to-many relationship, you must create a third table, often called a junction table, that breaks down the many-to-many relationship into two one-to-many relationships. You insert the primary key from each of the two tables into the third table. As a result, the third table records each occurrence, or instance, of the relationship. For example, the Orders table and the Products table have a many-to-many relationship that is defined by creating two one-to-many relationships to the Order Details table. One order can have many products, and each product can appear on many orders.
  • A one-to-one relationship
    In a one-to-one relationship, each record in the first table can have only one matching record in the second table, and each record in the second table can have only one matching record in the first table. This relationship is not common because, most often, the information related in this way is stored in the same table. You might use a one-to-one relationship to divide a table with many fields, to isolate part of a table for security reasons, or to store information that applies only to a subset of the main table. When you do identify such a relationship, both tables must share a common field.
Top of Page
Why create table relationships?

You can create table relationships explicitly by using the Relationships window, or by dragging a field from the Field List pane. Access uses table relationships to decide how to join tables when you need to use them in a databa se obj ect. There are several reasons why you should create table relationships before you create other databa se obj ects, such as forms, queries and reports.
  • Table relationships inform your query designs
    To work with records from more than one table, you often must create a query that joins the tables. The query works by matching the values in the primary key field of the first table with a foreign key field in the second table. For example, to return rows that list all of the orders for each customer, you construct a query that joins the Customers table with the Orders table **ba**sed on the Customer ID field. In the Relationships window, you can manually specify the fields to join. But, if you already have a relationship defined between the tables, Access supplies the default join, **ba**sed on the existing table relationship. In addition, if you use one of the query wizards, Access uses the information it gathers from the table relationships you have already defined to present you with informed choices and to prepopulate property settings with appropriate default values.
  • Table relationships inform your form and report designs
    When you design a form or report, Access uses the information it gathers from the table relationships you have already defined to present you with informed choices and to prepopulate property settings with appropriate default values.
  • Table relationships are the foundation upon which you can enforce referential integrity to help prevent orphan records in your databa se. An orphan record is a record with a reference to another record that does not exist — for example, an order record that references a customer record that does not exist.
    When you design a databa se, you divide your information into tables, each of which has a primary key. You then add foreign keys to related tables that reference those primary keys. These foreign key-primary key pairings form the basis for table relationships and multi-table queries. It’s important that these foreign key-primary key references stay synchronized. Referential integrity, which is dependent on table relationships, helps ensure that references stay synchronized.
Top of Page
Understanding referential integrity

When you design a databa se, you divide your databa se information into many subject-************d tables to minimize data redundancy. You then give Access a way to bring the data back together by placing common fields into related tables. For example, to represent a one-to-many relationship you take the primary key from the "one" table and add it as an additional field to the "many" table. To bring the data back together, Access takes the value in the "many" table and looks up the corresponding value in the "one" table. In this way the values in the "many" table reference the corresponding values in the "one" table.
Suppose you have a one-to-many relationship between Shippers and Orders and you want to delete a Shipper. If the shipper you want to delete has orders in the Orders table, those orders will become "orphans" when you delete the Shipper record. The orders will still contain a shipper ID, but the ID will no longer be valid, because the record that it references no longer exists.
The purpose of referential integrity is to prevent orphans and keep references in sync so that this hypothetical situation never occurs.
You enforce referential integrity by enabling it for a table relationship (see Enforce referential integrity for step-by-step instructions). Once enforced, Access rejects any operation that violates referential integrity for that table relationship. This means Access will reject both updates that change the target of a reference, and deletions that remove the target of a reference. It’s possible you might have a perfectly valid need to change the primary key for a shipper that has orders in the Orders table. For such cases, what you really need is for Access to automatically update all the effected rows as part of a single operation. That way, Access ensures that the update is completed in full so that your datab ase is not left in an inconsistent state, with some rows updated and some not. For this reason Access supports the Cascade Update Related Fields option. When you enforce referential integrity and choose the Cascade Update Related Fields option, and you then update a primary key, Access automatically updates all fields that reference the primary key.
It's also possible you might have a valid need to delete a row and all related records — for example, a Shipper record and all related orders for that shipper. For this reason, Access supports the Cascade Delete Related Records option. When you enforce referential integrity and choose the Cascade Delete Related Records option, and you then delete a record on the primary key side of the relationship, Access automatically deletes all records that reference the primary key.
Top of Page
View table relationships

To view your table relationships, click Relationships on the datab ase Tools tab. The Relationships window opens and displays any existing relationships. If no table relationships have been defined and you are opening the Relationships window for the first time, Access prompts you to add a table or query to the
Open the Relationships window

  • Click File, and then click Open.
  • Select and open the data************.
  • On the data************ Tools tab, in the Relationships group, click Relationships.

    If the data************ contains relationships, the Relationships window appears. If the databa se does not contain any relationships and you are opening the Relationships window for the first time, the Show Table dialog box appears. Click Close to close the dialog box.
  • On the Design tab, in the Relationships group, click All Relationships.

    This displays all of the defined relationships in your databas e. Note that hidden tables (tables for which the Hidden check box in the table's Properties dialog box is selected) and their relationships will not be shown unless the Show Hidden
    Objec tss check box is selected in the Navigation Options dialog box.
A table relationship is represented by a relationship line drawn between tables in the Relationships win A relationship that does not enforce referential integrity appears as a thin line between the common fields supporting the relationship. When you select the relationship by clicking its line, the line thickens to indicate it is selected. If you enforce referential integrity for this relationship, the line appears thicker at each end. In addition, the number 1 appears over the thick portion of the line on one side of the relationship, and the infinity symbol () appears over the thick portion of the line on the other side.
When the Relationships window is active, you can select from the following commands on the ribbon:
On the Design tab, in the Tools group:
  • Edit Relationships Opens the Edit Relationships dialog box. When you select a relationship line, you can click Edit Relationships to change the table relationship. You can also double-click the relationship line.
  • Clear Layout Removes all tables and relationships from display in the Relationships ************************ Note that this command only hides the tables and relationships — it does not delete them.
  • Relationships Report Creates a report that displays the tables and relationships in your data************. The report shows only the tables and relationships that are not hidden in the Relationships ************************
On the Design tab, in the Relationships group:
  • Show Table Opens the Show Table dialog box so that you can select tables and queries for viewing in the Relationships ************************
  • Hide Table Hides the selected table in the Relationships ************************
  • Direct Relationships Displays all relationships and related tables for the selected table in the Relationships window, if they are not already displayed.
  • All Relationships Displays all of the relationships and related tables in your data************ in the Relationships ************************ Note that hidden tables (tables for which the Hidden check box in the table's Properties dialog box is selected) and their relationships will not be shown unless Show Hidden ******************s is selected in the Navigation Options dialog box.
  • Close Closes the Relationships ************************ If you made any changes to the layout of the Relationships window, you are asked whether to save those changes.

WileyRot غير متواجد حالياً
رد مع اقتباس
رسالة لكل زوار منتديات العبير

عزيزي الزائر أتمنى انك استفدت من الموضوع و لكن من اجل منتدى ارقي و ارقي برجاء عدم نقل الموضوع و يمكنك التسجيل معنا و المشاركة معنا و النقاش في كافه المواضيع الجاده اذا رغبت في ذلك فانا لا ادعوك للتسجيل بل ادعوك للإبداع معنا . للتسجيل اضغظ هنا .

قديم 21-08-2019, 02:07 AM   #2

الصورة الرمزية عبد الله الساهر

 رقم العضوية :  1
 تاريخ التسجيل :  22-07-2004
 المشاركات :  69,691
 الدولة :  ムレ3乃乇乇尺
 الجـنـس :  ذكر
 العمر :  37
 عدد النقاط :  243859
 قوة التقييم :  عبد الله الساهر تم تعطيل التقييم
 SMS :

حتى لو اجتهدت و قطعت فؤادك.. ووضعته للناس في طبق فضي ليرضوا عنك لن تفلح وربما لن تصل لمستوى يرضيك أنت عن نفسك فاجتهد ليكون الله وحده راضياً عنك وأغمض عينيك عن ما سواه

 اخر مواضيع » عبد الله الساهر
 تفاصيل مشاركات » عبد الله الساهر
 أوسمة و جوائز » عبد الله الساهر
 معلومات الاتصال بـ عبد الله الساهر

افتراضي رد: Guide to table relationships


الله يجزاك خير ويكتب اجرك

توقيع :





رحمك الله يا أنس
وجعل الفردوس دارك ومستقرك



عبد الله الساهر متواجد حالياً
رد مع اقتباس
قديم 28-08-2019, 12:55 PM   #3


 رقم العضوية :  125807
 تاريخ التسجيل :  28-08-2019
 المشاركات :  8
 الجـنـس :  ذكر
 عدد النقاط :  10
 قوة التقييم :  محمد العمار is on a distinguished road
 اخر مواضيع » محمد العمار
 تفاصيل مشاركات » محمد العمار
 أوسمة و جوائز » محمد العمار
 معلومات الاتصال بـ محمد العمار

افتراضي رد:


جزاكم الله خير

محمد العمار غير متواجد حالياً
رد مع اقتباس
قديم 11-09-2019, 02:34 PM   #4
مشرفة الأحتياجات الخاصة

الصورة الرمزية عزوف

 رقم العضوية :  57209
 تاريخ التسجيل :  17-11-2009
 المشاركات :  24,503
 الدولة :  طالبها بالحياة
 الجـنـس :  أنثى
 عدد النقاط :  68680
 قوة التقييم :  عزوف has much to be proud ofعزوف has much to be proud ofعزوف has much to be proud ofعزوف has much to be proud ofعزوف has much to be proud ofعزوف has much to be proud ofعزوف has much to be proud ofعزوف has much to be proud ofعزوف has much to be proud ofعزوف has much to be proud ofعزوف has much to be proud of
 SMS :

من الجيد اننا نكتب من خلف الشاشة ومن الجيد جدا انة لا احد يستطيع التاكد من كوننا نبكي ام لا

 اخر مواضيع » عزوف
 تفاصيل مشاركات » عزوف
 أوسمة و جوائز » عزوف
 معلومات الاتصال بـ عزوف

افتراضي رد: Guide to table relationships


مشكورهـ الله يعطيك العافية

توقيع :

آللهم ’
إن بين ضلوعي ( أُمْنـيَـة ) !
يتمنآهآ قلبي وروحي و عقلي . .
فلآ تحرمني من - فرحة - تحقيقهآ ،
فَ إنگ وحدگ من تقول :

گن ف يكوووووون

عزوف غير متواجد حالياً
رد مع اقتباس
قديم 02-10-2019, 03:10 PM   #5


 رقم العضوية :  126034
 تاريخ التسجيل :  02-10-2019
 المشاركات :  15
 الجـنـس :  أنثى
 عدد النقاط :  10
 قوة التقييم :  chrome is on a distinguished road
 اخر مواضيع » chrome
 تفاصيل مشاركات » chrome
 أوسمة و جوائز » chrome
 معلومات الاتصال بـ chrome

افتراضي رد:


الله يعطيك العافية

chrome غير متواجد حالياً
رد مع اقتباس
إضافة رد

مواقع النشر (المفضلة)

أدوات الموضوع
انواع عرض الموضوع

تعليمات المشاركة
لا تستطيع إضافة مواضيع جديدة
لا تستطيع الرد على المواضيع
لا تستطيع إرفاق ملفات
لا تستطيع تعديل مشاركاتك

BB code is متاحة
كود [IMG] متاحة
كود HTML معطلة
Trackbacks are متاحة
Pingbacks are متاحة
Refbacks are متاحة



الساعة الآن 06:07 PM


Powered by vBulletin® Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.6.0 TranZ By Almuhajir
Ads Organizer 3.0.3 by Analytics - Distance Education
جميع الحقوق محفوظة لـ : منتديات العبير
المحتوى المنشور فى موقع العبير لايعبر بالضرورة عن وجهة نظر الإدارة وإنما يعبر عن وجهة نظر كاتبها