473,395 Members | 1,568 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,395 software developers and data experts.

Relationships... who needs em anyways?

blyxx86
256 100+
I am having the darndest time trying to get this relationship working easily.

The areas where I'm having the hardest time of relating information is where there are multiple branches relating one table to multiple tables.

You see where ModelNumber in the tblModels table connects to ModelNumber in tblMainA, tblOutDetail, tblInbDetail...

Well if I were to go into that table and click the little plus arrow next to the record, it asks me to choose a relationship. Then I can't choose another after I close the table. How do I modify that?

Also, if you see any issues within the relationship, please let me know. I'm open for suggestions.

See relationship chart here
Feb 16 '07 #1
22 2199
MMcCarthy
14,534 Expert Mod 8TB
tblMainA Stores the Model Number so you don't need to store it in tblInbDetail and tblOutDetail. This is duplication as tblMainA has an indirect relationhip to these tables.

Mary
Feb 16 '07 #2
blyxx86
256 100+
I figured out how to modify the "Subdatasheet" of a table.

Also..

The suggestion you made. I believe it would limit my users to select only the model suggested in tblMainA?

I think it's doing that now anyways... I guess what I need to do is be able to put different ModelNumber's in each of the 'tblInbDetail' and 'tblOutDetail' ... is that just me using a lookup field instead of a relationship?

Multilevel relationships are not something I am used to working with, so this is all foreign to me.

My goal is this.

tblMainA contains a 'Requested Model'
tblOutDetail and tblInbDetail contain the actual 'ModelNumber' that was shipped/received.

How would I then relate the tables so that it is accurate. Requested model, shipped model, received model.

I don't know if I am making sense, but if you need more information regarding this, please let me know.
Feb 16 '07 #3
NeoPa
32,556 Expert Mod 16PB
From simple observation I would advise merging the two pairs of tables :
tblInb with tblOut and tblInbDetail with tblOutDetail.
A flag field may be added to separate the 'In's from the 'Out's in both cases.
Have a look through (Normalisation and Table structures) for a fuller explanation.
Feb 17 '07 #4
MMcCarthy
14,534 Expert Mod 8TB
I figured out how to modify the "Subdatasheet" of a table.

Also..

The suggestion you made. I believe it would limit my users to select only the model suggested in tblMainA?

I think it's doing that now anyways... I guess what I need to do is be able to put different ModelNumber's in each of the 'tblInbDetail' and 'tblOutDetail' ... is that just me using a lookup field instead of a relationship?
Yes

Multilevel relationships are not something I am used to working with, so this is all foreign to me.

My goal is this.

tblMainA contains a 'Requested Model'
tblOutDetail and tblInbDetail contain the actual 'ModelNumber' that was shipped/received.

How would I then relate the tables so that it is accurate. Requested model, shipped model, received model.

I don't know if I am making sense, but if you need more information regarding this, please let me know.
Firstly rename the ModelNumber fields to indicate the differences between them and as you said earlier this is just a table lookup rather than what is considered a relationship. What are you trying to do that is not working. I get the impression from a previous post that you are trying to add a second relationship between two tables, why and where?

Mary
Feb 18 '07 #5
blyxx86
256 100+
Yes



Firstly rename the ModelNumber fields to indicate the differences between them and as you said earlier this is just a table lookup rather than what is considered a relationship. What are you trying to do that is not working. I get the impression from a previous post that you are trying to add a second relationship between two tables, why and where?

Mary
I will make some modifications to the relationships today and give it another go.

I really do appreciate your help on this. I have a feeling it's going to get more complicated over the next couple days in terms of the queries I'm going to need to create, but I think I will be able to manage those and any aggregate functions that are included within. I've just been having troubles setting up relationships. This is my first database with somewhat complex relationships. My other databases have contained only a couple one-to-many relationships. So this is all a leap forward.

One question though. When I use the lookup wizard, it creates a relationship for me. I know it doesn't require the relationship, but will deleting that make anything bad happen down the line?
Feb 19 '07 #6
MMcCarthy
14,534 Expert Mod 8TB
I will make some modifications to the relationships today and give it another go.

I really do appreciate your help on this. I have a feeling it's going to get more complicated over the next couple days in terms of the queries I'm going to need to create, but I think I will be able to manage those and any aggregate functions that are included within. I've just been having troubles setting up relationships. This is my first database with somewhat complex relationships. My other databases have contained only a couple one-to-many relationships. So this is all a leap forward.

One question though. When I use the lookup wizard, it creates a relationship for me. I know it doesn't require the relationship, but will deleting that make anything bad happen down the line?
The wizard creates the relationship and this is correct so don't delete it. You just have to think of it differently. Lookup tables are not normally included in queries unless associated information is required.

Remember you don't need to have a relationship between table A and C if there is already a relationship between tables A and B and tables B and C as you can use these relationships in any query on tables A and C.

Mary
Feb 19 '07 #7
blyxx86
256 100+
The wizard creates the relationship and this is correct so don't delete it. You just have to think of it differently. Lookup tables are not normally included in queries unless associated information is required.

Remember you don't need to have a relationship between table A and C if there is already a relationship between tables A and B and tables B and C as you can use these relationships in any query on tables A and C.

Mary
Then what's the purpose of the relationship if it doesn't really do anything?

Does the lookup query require the relationship to function correctly since it is using a SQL statement to get the information for the Drop down.

I will have to take a breather and try to reorganize my thoughts and questions on the matter. Because I require that the ModelNumber in the far right tables be influenced by 'referential integrity cascades.' So the requirement for them to be related via a one-to-many relationship is still required... I think?
Feb 20 '07 #8
MMcCarthy
14,534 Expert Mod 8TB
Then what's the purpose of the relationship if it doesn't really do anything?

Does the lookup query require the relationship to function correctly since it is using a SQL statement to get the information for the Drop down.

I will have to take a breather and try to reorganize my thoughts and questions on the matter. Because I require that the ModelNumber in the far right tables be influenced by 'referential integrity cascades.' So the requirement for them to be related via a one-to-many relationship is still required... I think?
So if you delete a model number you want every record referencing that model number to be deleted?

Mary
Feb 20 '07 #9
blyxx86
256 100+
So if you delete a model number you want every record referencing that model number to be deleted?

Mary
Well, what I want to do is ... probably not very complicated.





We have the ReqModelNumber in a one-to-many relationship.

There is no relationship binding 'ModelNumber' in the table "tblOutDetail" but if the ModelNumber changes in the original 'tblModels' table then that update will not cascade to the 'tblOutDetail'

The database is still in design mode, and I'm trying to think of any possible future proof things I can before I release it to the hounds (aka coworkers).
Feb 20 '07 #10
MMcCarthy
14,534 Expert Mod 8TB

We have the ReqModelNumber in a one-to-many relationship.

There is no relationship binding 'ModelNumber' in the table "tblOutDetail" but if the ModelNumber changes in the original 'tblModels' table then that update will not cascade to the 'tblOutDetail'

The database is still in design mode, and I'm trying to think of any possible future proof things I can before I release it to the hounds (aka coworkers).
Using the model number as the primary key is going to be a problem if you are going to ever invision changing the model number.

Rule#1:
THE VALUE OF A PRIMARY KEY INVOLVED IN A RELATIONSHIP SHOULD NEVER CHANGE.

Having got that out of the way create a new autonumber primary key and take the primary key off model number. Now create a new foreign key field in tblMainA to reference this new ID and update to the ID where modelNumber in lookup table is the same as the old primary key. You can now delete the old foreign key reference to modelNumber and if you change the model number in the tblModels it won't change the primary key so the reference remains the same. Do the same for any other tables with a relationship to tblModels.

Mary
Feb 21 '07 #11
blyxx86
256 100+
Using the model number as the primary key is going to be a problem if you are going to ever invision changing the model number.

Rule#1:
THE VALUE OF A PRIMARY KEY INVOLVED IN A RELATIONSHIP SHOULD NEVER CHANGE.

Having got that out of the way create a new autonumber primary key and take the primary key off model number. Now create a new foreign key field in tblMainA to reference this new ID and update to the ID where modelNumber in lookup table is the same as the old primary key. You can now delete the old foreign key reference to modelNumber and if you change the model number in the tblModels it won't change the primary key so the reference remains the same. Do the same for any other tables with a relationship to tblModels.

Mary
I was a step ahead of this before I got to reading it. I understand the rule, but then what is the purpose of the 'cascade updates' if a primary key is not supposed to change? cascade delete, i can see the purpose in any case (although kinda scary at the same time)

the 'modelnumber' shouldn't ever change and i would like to leave it as a primary key, but at the same time I can understand that setting up an autonumber field would work too.

I've since modified the relationship again, but what conceptual flaws do you see with the current design. With lookups for the two tables (tblInbDetail / tblOutDetail) ... or do you feel that the relationships have been, mostly, set up correctly now?
Feb 21 '07 #12
NeoPa
32,556 Expert Mod 16PB
Rule#1:
THE VALUE OF A PRIMARY KEY INVOLVED IN A RELATIONSHIP SHOULD NEVER CHANGE.
I was a step ahead of this before I got to reading it. I understand the rule, but then what is the purpose of the 'cascade updates' if a primary key is not supposed to change?
The rule that Mary is quoting is a recommendation of how things should work.
Access will not constrain you to doing things in the recommended way. If you choose to change the PK then Access can handle making sure all related FKs are changed to match.
Feb 21 '07 #13
blyxx86
256 100+
The rule that Mary is quoting is a recommendation of how things should work.
Access will not constrain you to doing things in the recommended way. If you choose to change the PK then Access can handle making sure all related FKs are changed to match.
NeoPa,

In regards to your earlier suggestion about merging the two tables together (Inb and Out) my only concern there is that there are differences between the two (additional fields I have only recently added like 'Date') which can vary between inbound and outbound.

I can see how combining the two 'detail' tables could work out to be beneficial however. I can possibly think of a way to merge the 'Inb' and 'Out' tables, but I'm worried that the queries relating to that table would become more complex by being combined.

One conceptual question for you.. Is there a rule that would state a PK in one table should not be a FK in multiple tables? Like in my example of the 'Incident' being bound to the 'tblInb' and 'tblOut' tables?
Feb 22 '07 #14
NeoPa
32,556 Expert Mod 16PB
In regards to your earlier suggestion about merging the two tables together (Inb and Out) my only concern there is that there are differences between the two (additional fields I have only recently added like 'Date') which can vary between inbound and outbound.
I can see how combining the two 'detail' tables could work out to be beneficial however.
Unless there are a large number of such fields I would just add the field anyway and leave it set to Null (unused) for those records (or the types) that don't need them.
I can possibly think of a way to merge the 'Inb' and 'Out' tables, but I'm worried that the queries relating to that table would become more complex by being combined.
I can see you're getting to grips with some of the database concepts that make life so much easier once understood (We'll make an expert of you yet :)). Basically it's a different way of thinking about databases and how they work. For me now, I actually find dealing with a single table but with JOINs or a WHERE clause to specify a filter of which records are selected, easier than working with multiple tables whose relationships and MetaData need to be bourne in mind when working with them. I would recommend storing the similar data together in one table.
One conceptual question for you.. Is there a rule that would state a PK in one table should not be a FK in multiple tables? Like in my example of the 'Incident' being bound to the 'tblInb' and 'tblOut' tables?
I don't think so (You could check (Normalisation and Table structures) but I don't remember seeing it).
Feb 22 '07 #15
MMcCarthy
14,534 Expert Mod 8TB
One conceptual question for you.. Is there a rule that would state a PK in one table should not be a FK in multiple tables? Like in my example of the 'Incident' being bound to the 'tblInb' and 'tblOut' tables?
No there isn't. Think of this example.

tblCustomers
CustID (Primary Key)
CustName

tblOrders
OrderID (Primary Key)
Product
CustID (Foreign Key referencing Primary key of Customer table)

tblInvoices
InvNumber (Primary Key)
InvDate
InvAmount
CustID (Foreign Key referencing Primary key of Customer table)

In this case CustID the primary key of the tblCustomers table is referenced by both the tblOrders and the tblInvoices table. However, there in no relationship between tblOrders and tblInvoices. This is the correct and classic structure for this kind of database.

Mary
Feb 22 '07 #16
blyxx86
256 100+
No there isn't. Think of this example.

tblCustomers
CustID (Primary Key)
CustName

tblOrders
OrderID (Primary Key)
Product
CustID (Foreign Key referencing Primary key of Customer table)

tblInvoices
InvNumber (Primary Key)
InvDate
InvAmount
CustID (Foreign Key referencing Primary key of Customer table)

In this case CustID the primary key of the tblCustomers table is referenced by both the tblOrders and the tblInvoices table. However, there in no relationship between tblOrders and tblInvoices. This is the correct and classic structure for this kind of database.

Mary
Yet... there is a relationship between them, although not directly? They are both tied to the Customer table.

I modeled my current design after something similar to that example. Because an "Incident" is like a customer, then the 'outbound' is like the order and then the 'detail' is the contents of the order.

There are going to be a great number of fields and records for both tblInb and tblOut so while the data is similar, It is also opposite of one another (Inbound versus Outbound)

I wouldn't mind using a single table, but I doubt I'll be able to, so I'll just have to design a query that will gather the pertinent information to have it display as a table for me.

I don't want to even think of the forms I need to create for my co-workers. Although anything would be an improvement over their current record keeping of excel spreadsheets. Try finding a specific 'Incident' in 2 years worth of daily spreadsheets. NO THANK YOU.

I hope that once everyone here helps me become an expert (although you have called me that once before NeoPa) and I begin designing databases for my work that I will get a pay increase. Do you by chance know the average salary for a DBA? I just recently turned 20 years old so I've got a lot of school ahead of me, and I am currently enrolled in two classes on database design because I find it extremely interesting. However, the first 8 weeks have been basic basic functions like using a static select query to find "john smith" in a table.
Feb 23 '07 #17
blyxx86
256 100+
Check out the new relationships I've created:
New Relationships Layout

Take a look at that new table layout and let me know what you think. I try to follow the Normalization you've suggested and I FEEL that it's in 3rd at least. However, I'd like to know what you think.

I know I need to make a couple changes in terms of PK and allowing some units to be shipped out and returned without an "Incident" number. So I'm going to have to ponder on that for a little while longer.

I'd like to just know where I didn't do the relationships properly.

I decided to keep the 'Out' and 'Inb' separate because they are related in terms of being opposites, although with similar data.. so I'm still a little confused as to what I should do.
Feb 27 '07 #18
MMcCarthy
14,534 Expert Mod 8TB
1. You are relating tblPrimary to tblAnalyst and tblPrimary to tblCustomer and tblAnalyst to tblCustomer. This is one relationship too many.

If tblPrimary has an Analyst who is then related to a Customer then remove customer from tblPrimary

OR

If tblPrimary has a custome who is related to an Analyst then remove Analyst from tblPrimary.

2. For the same reasons why is customer in tblModels

3. I understand from previous conversations that ModelNumber is essentially a lookup table.

If tblPrimary references a Customer then all other tables referenced directly or indirectly by that table will have an indirect reference to the customer and don't need to store it.

Mary
Feb 27 '07 #19
blyxx86
256 100+
1. You are relating tblPrimary to tblAnalyst and tblPrimary to tblCustomer and tblAnalyst to tblCustomer. This is one relationship too many.

If tblPrimary has an Analyst who is then related to a Customer then remove customer from tblPrimary

OR

If tblPrimary has a custome who is related to an Analyst then remove Analyst from tblPrimary.

2. For the same reasons why is customer in tblModels

3. I understand from previous conversations that ModelNumber is essentially a lookup table.

If tblPrimary references a Customer then all other tables referenced directly or indirectly by that table will have an indirect reference to the customer and don't need to store it.

Mary
I guess the reasoning behind having the customer in so many locations is that "tblAnalyst" stores information that is specific to each customer, then also some models are specific to each customer as well.

Each analyst is related to a customer, and each analyst is also related to many incidents.

Many incidents are related to one customer.

I could delete the relationship between 'tblCustomer' and 'tblModels' at least for now.

Other than that, is there any other problems you can see? Is it too complicated with all the little guys flying all over the place?
Feb 27 '07 #20
MMcCarthy
14,534 Expert Mod 8TB
If there is one Analyst record per customer then you don't need analyst in the incident table as it can be referenced through the customer table.

Your problem is you have too many circular references. This is going to cause you endless problems.

Mary
Feb 27 '07 #21
blyxx86
256 100+
If there is one Analyst record per customer then you don't need analyst in the incident table as it can be referenced through the customer table.

Your problem is you have too many circular references. This is going to cause you endless problems.

Mary
How would you fix that problem?

There are many analysts per customer, but only one analyst per incident.



There are still technically lookup values in the 'Primary' table to the model, but they do not have relationships anymore. Will that cause any type of problem?
Feb 27 '07 #22
MMcCarthy
14,534 Expert Mod 8TB
OK

An Incident which is recorded in tblPrimary has one and only one analyst and one and only one customer. Each Analyst handles many incidents and each customer can have many incidents. Each Analyst can work for many customers.

Big question ...Can each Customer have more than one analyst. That is does customer A only ever work with analyst B. What is the full relationship between customers and analysts.

Mary
Feb 28 '07 #23

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

Similar topics

6
by: Chuck Van Den Corput | last post by:
I have an application with one main table with a jillion attributes. There are numerous other tables, but these are either children of the main table or lookup tables. I am finding that I am...
2
by: Megan | last post by:
hello everybody, i know this is a very long post, but i wanted to provide as much detail as possible. quick overview- i want to create a couple of many to many relationships and am wondering...
3
by: LoopyNZ | last post by:
Hi, I'd like to have a couple of buttons on my form so I can quickly access some Access (97) features: A) The relationships window; B) Tools - Analyze - Documenter (for relationships). ...
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...
3
by: Tom | last post by:
Hi: I have a question on how best to accomplish the following design requirements: I have the following tables: tblPeople (identifies a person) >PersonID as PK >all the other usual fields
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...
2
by: DevNull | last post by:
Hello Everyone, Recently I was assigned the joyful task of creating a modern work-alike of an application from the 1980's. Without delving into too much detail, my job is to create a web based...
5
by: Ron | last post by:
Hi All, Development stage of setting up a new solution here. I CONSTANTLY have to unhook the relationships I've built via the Relationships tab on Tools, then change the Required element of a...
1
by: cricket7 | last post by:
I think I figured out my tables and relationships. Tables: Table 1 tblTowedVehicles fldTowID fldReportDate fldReportTime fldlReportNumber
1
desklamp
by: desklamp | last post by:
Access 2003 on Win2K The tables involved: an IP address table, tblIP, where basic IP address information is stored: IP, WHOIS, reverse DNS name, etc. an event IP table, tblIPEvent, where...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.