473,382 Members | 1,357 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Discussion: About Relationships

759 512MB
NeoPa:
This is a question that was asked in another thread (Populating Junction Table & Many to Many Relationship). Please understand this (hijacking) is not allowed on this site.
Only to learn (teach) myself:

For me sound as one to many relationship.
One business with many policies.
Am I wrong ?
Mar 20 '12 #1

✓ answered by mshmyob

A simple way to determine the relationship type between tables is like so:

You MUST always have 2 rules for each set of related tables. I like to call them bi-directional rules.

So in this case the 2 tables tblPolicy and tblDepartment are related to each other. The question is "how are they related?". To determine that create 2 rules that go in opposite directions like so (always start the rule with the word ONE)

From tblPolicy ---> tblDepartment
ONE policy can be applied to MANY departments (1:M) - Notice the Many side is on tblDepartment

From tblDepartment ---> tblPolicy
ONE department can have MANY policies (1:M) - Notice the Many side is on tblPolicy.

Therefore you have a MANY on the tblDepartment and a MANY on the tblPolicy resulting in a M:N relationship - bridge table required. The minimum fields in a bridge table are the PK fields from the adjoining tables making them FK's in bridge table when looked at seperately.

With a slight change to the business rules you get a different relationship type and therefore a different design. Assume the rules changed like so:

From tblPolicy ---> tblDepartment
ONE policy can be applied to ONE department (1:1) - Notice the ONE side is now also on tblDepartment

From tblDepartment ---> tblPolicy
ONE department can have MANY policies (1:M) - Notice the Many side is on tblPolicy.

You therefore now have a 1:M relationship between tblDepartment and tblPolicy and no bridge table is needed. The foreign key goes in the tblPolicy table (note: FK ALWAYS goes to the MANY side).

cheers,

9 2087
sg2808
91
Here Business indicates Business areas (different departments) and therefore many to many relationship.
Mar 20 '12 #2
Mihail
759 512MB
I am not so sure, SG.
I think is only a problem with view points.

If I can define, for a certain Department, a list with the policies using by that Department means that I have a relation One Department to many policies.
but
If I can define a list, for a certain policy, with Departments that uses that policy means that I have a relation One Policy to many Departments

So, in my opinion, this is a One to Many relationship. The direction (vector) is a choice to made at design time.

This is the reason I ask the experts.
Hope they can answer me from the database view point not from your reality view point.
Mar 20 '12 #3
NeoPa
32,556 Expert Mod 16PB
Mihail:
Am I wrong ?
Yes. Absolutely. Unless your English is really bad today then this is just wrong.
I would add here though, that any understanding that you might have been disrespectful of anyone in the thread is mistaken. I know that was merely down to difficulties with the language.

Many-to-Many (M:N) relationships are often required and the original question very much appears to be a good example of such a requirement.

Implementing such a relationship is typically done with a 'bridging' table, as illustrated clearly by Mshmyob in his post #2 of the linked thread. Such a table includes FKs to both tables within the M:N relationship. Each of the FKs is connected to the other table using a One-to-Many (1:M) link. Only together are they considered to reflect an M:N relationship.
Mar 20 '12 #4
Mihail
759 512MB
:) No NeoPa.
My English is as you know.

I fully agree with the "bridge" table. No doubt.

@NeoPa:
Each of the FKs is connected to the other table using a One-to-Many (1:M) link. Only together are they considered to reflect an M:N relationship.


This enlightened me and show (to me) my mistake.
Also is first time I have a REAL explanation for Many to Many relation ship. Finally I understand that !
This is why I wanted to hear an explanation from an expert in databases.
Thank you a lot !

And thank you for this new thread too !
Mar 20 '12 #5
NeoPa
32,556 Expert Mod 16PB
Pleased to help Mihail.

Indeed I know how you struggle with English, but at least you do. You make the effort, which is commendable.
Mar 20 '12 #6
mshmyob
904 Expert 512MB
A simple way to determine the relationship type between tables is like so:

You MUST always have 2 rules for each set of related tables. I like to call them bi-directional rules.

So in this case the 2 tables tblPolicy and tblDepartment are related to each other. The question is "how are they related?". To determine that create 2 rules that go in opposite directions like so (always start the rule with the word ONE)

From tblPolicy ---> tblDepartment
ONE policy can be applied to MANY departments (1:M) - Notice the Many side is on tblDepartment

From tblDepartment ---> tblPolicy
ONE department can have MANY policies (1:M) - Notice the Many side is on tblPolicy.

Therefore you have a MANY on the tblDepartment and a MANY on the tblPolicy resulting in a M:N relationship - bridge table required. The minimum fields in a bridge table are the PK fields from the adjoining tables making them FK's in bridge table when looked at seperately.

With a slight change to the business rules you get a different relationship type and therefore a different design. Assume the rules changed like so:

From tblPolicy ---> tblDepartment
ONE policy can be applied to ONE department (1:1) - Notice the ONE side is now also on tblDepartment

From tblDepartment ---> tblPolicy
ONE department can have MANY policies (1:M) - Notice the Many side is on tblPolicy.

You therefore now have a 1:M relationship between tblDepartment and tblPolicy and no bridge table is needed. The foreign key goes in the tblPolicy table (note: FK ALWAYS goes to the MANY side).

cheers,
Mar 20 '12 #7
NeoPa
32,556 Expert Mod 16PB
That's a great post and lays out the situation very clearly - especially for those learning how to work with relationships. Nice :-)
Mar 20 '12 #8
Mihail
759 512MB
Indeed, NeoPa, even if he say the same as you.
I am sure you agree that mshmyob's post is the really best answer.

Until now :)
Mar 21 '12 #9
NeoPa
32,556 Expert Mod 16PB
: - )
Mar 21 '12 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

20
by: Ed | last post by:
I am running Access 2002 and just ran the built in Access wizard for splitting a database into a back end (with tables) and front end (with queries, forms, modules, etc.). After running the...
0
by: Megan | last post by:
Hi Everybody- I know that this is a really, really long post, but I wanted to try to give you as much background as possible. So here's a quick overview of the issues I'm asking for help with:...
2
by: Max | last post by:
Hi. I really hope someone can help me. Going slowly insane with this problem. I have a two Access 2000 databases. One is the backend containing tables and some admin queries. The other is the...
11
by: BillCo | last post by:
I'm using a backend that's been around for years before I joined the company. It kind of grew exponentially and has some design problems including large unused tables some temporary tables. It...
7
by: davegb | last post by:
I'm totally new to relational database design. My boss has asked me to create a database of information on the employees in our group. Seemed to me like a simple application to learn the ropes. A...
10
by: Dixie | last post by:
I need to delete some relationships in code. How do I know what the names of those relationships are?
45
by: salad | last post by:
I'm curious about your opinion on setting relationships. When I designed my first app in Access I'd go to Tools/Relationships and set the relationships. Over time I'd go into the window and see...
4
by: celinesuzzarini | last post by:
Hi all, I have split my database a while ago, and now, I want to add a table with relationships to other existing tables. I open the BE, create my table, and then go to the relationships...
13
by: ARC | last post by:
Hello all, Prior to going live with my app, I have questions on relationships theory. My prior app was done in Access 97, and I did NOT use relationships at all. I have 65 tables in my...
8
by: Phil Stanton | last post by:
I have a FE, BE database on my home computer and a duplicate on the office computer. Both use Ak2 on Windows XP. The one at home appears normal. The BE consists of about 50 tables with numerous...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.