Creating reletionship

sven2

Registered User.
Local time
Today, 11:22
Joined
Apr 28, 2007
Messages
297
Hello,

I have some trouble with creating the right relationships between my tables.
What do I have so far ...

I have a table called machine tha is linked to a table machineparts (machineonderdelen) that again is linked to a table parameters (kwaliteitsgegevens).

Now my problem is the next table. This table represent the product. So the intension is when I add a product that is made on one of the machines all the parameters that are active fore this machine in the table kwaliteitsgegevens should be obliged to fill in.

How can i do this.

I have also put an example to this message.

Thanks in advance,
Sven.
 

Attachments

You have composite keys (multiple PK's) in two tables: tblMoederrollen and TblMachineonderdeel. From the way it looks, this should not be. I would drop the PK on MachineID in both of these tables, as this field should be on the many side of the relationship with the Machine field, and doesn't seem to serve much purpose for being a PK in more than one table (unless my interpretation is off here).

Also, if the table called "TblKwaliteitgegevens" is the product table, you also have too many PK's there. There could be more information offered to you, but to do that, could you maybe provide the table names in English (having trouble reading your language!), and an explanation of what data you are going to store in them?
 
Hello,

thanks for the information, but I still can't solve my problem.
As you asked the explanation about the tables:

there are 5 tables.

The first table (machine) is about machines that exists in the factory:
machineID = PK about the machine
machinenaam = machinename
actief = active (important for some query's)


The second table (machineonderdelen) is about machineparts:
MachineID = PK about the machine
CategorieID = PK about the machinepart
Categorienaam = name of the machinepart
actief = is the machinepart still active (important for some query's)

the third table (kwaliteitsgegevens) is about parameters. For each machinepart there are some parameters

kwaliteitID = PK about the parameter
CategorieID = PK about the machinepart
MachineID = PK about the machine
Kwaliteitsnaam = the parameter that belongs to a machinepart and machine
Actief = is this parameter still active


the fourth table (moederrollen) is about the product that is made on a machine.

Moederrolnummer = identification number of the product
machineID = PK about the machine
Papiersoort = information about hte product
papiergewicht = information about the product
datum = date
uur = hour


The fifth table is about the values for the product. For each moederrolnummer that is created all the parameters that are still active should be filled in in this table.

Thank in advance for the help.

Sven.
 
I just took a quick glance but I think you might want to think about foriegn keys : )

Hello,

thanks for the information, but I still can't solve my problem.
As you asked the explanation about the tables:

there are 5 tables.

The first table (machine) is about machines that exists in the factory:
machineID = PK about the machine
machinenaam = machinename
actief = active (important for some query's)


The second table (machineonderdelen) is about machineparts:
MachineID = PK about the machine
CategorieID = PK about the machinepart
Categorienaam = name of the machinepart
actief = is the machinepart still active (important for some query's)

the third table (kwaliteitsgegevens) is about parameters. For each machinepart there are some parameters

kwaliteitID = PK about the parameter
CategorieID = PK about the machinepart
MachineID = PK about the machine
Kwaliteitsnaam = the parameter that belongs to a machinepart and machine
Actief = is this parameter still active


the fourth table (moederrollen) is about the product that is made on a machine.

Moederrolnummer = identification number of the product
machineID = PK about the machine
Papiersoort = information about hte product
papiergewicht = information about the product
datum = date
uur = hour


The fifth table is about the values for the product. For each moederrolnummer that is created all the parameters that are still active should be filled in in this table.

Thank in advance for the help.

Sven.
 
Hello,

I'm sorry but I don't understand what you mean by foriegn keys ...

Best regards,
Sven.
 
Foreign Keys are the Primary Keys from Foreign tables. This is how you join tables together.
 
Sven,

I will read through your post and give you some feedback on it later today. To do it well though, can you offer an explanation of the term parameters?? I have seen that you use it a lot, and I think most programmers probably use the word in a different context from which you are using it. Can you tell me what you mean by that (when you say it)? Thanks! - (it sounds like you are just referring to some sort of "related" data in tables other than that to which you are speaking of).
 
Hello,

with parameters I mean figures that need to be stored in the database about the machine when making a product. For example the machinespeed is a parameter or the steampressure is a parameter.

I hope this is clear for you?

Thanks for the help,
Sven.
 
Yes it is. So, apparently the word parameter here describes the actual "fields" in a table. That's fine, just wanted to be clear. I'll get back to you in a while...
 
Hi Sven.
When you reference a table- ie. A parent table to a child table
You create a constraint called a foriegn key. This is how relationalship databases relate : ) The foriegn key has to reference a unique field or set of fields in the child table, the primary key. In the parent table you can have a foriegn key that help make the primary key. When you have more then one key that creates a primary key it is known as a composite key.

For your DB to work you will have to drop the PK's that from other tables and create foriegn keys. :)

Hello,

with paramaters I mean figures that need to be stored in the database about the machine when making a product. For example the machinespeed is a parameter or the steampressure is a parameter.

I hope this is clear for you?

Thanks for the help,
Sven.
 
Shouldn't you be working on your own problem Harley? ;) ;) ;) ;) ;) Yours is a bit more complicated than this one! :)
 
Hello,

I have changed my relationships but it is still not working. When I run a query with a conection between tblkwaliteitswaarde - tbl machine - tbl kwaliteitsgegevens the records are multiplied with a factor x.

So there is still something wrong with my relationships and I haven't got any idea what is wrong ...

Who can help??

Best regards,
Sven.
 

Attachments

which table is not relating properly?
what relationship do you want it to have : ) the foriegn words really throw me off in your tables, it makes it harder to understand the realworld relationships : ) so tell me how you want them to relate and i will attach it for you and tell you what I think the problem was.
Hello,

I have changed my relationships but it is still not working. When I run a query with a conection between tblkwaliteitswaarde - tbl machine - tbl kwaliteitsgegevens the records are multiplied with a factor x.

So there is still something wrong with my relationships and I haven't got any idea what is wrong ...

Who can help??

Best regards,
Sven.
 
Hello,

there are T tables:

TblMachine --> table with all the machines there are in the factory
TblKwaliteitsgegevens --> measurements that are to be registrated on the product
TblMoederrollen --> product that is made on these machines
TblMachineonderdeel --> machineparts
TblFreqentie --> the frequentie that the measurements needs to be done
TblKwaliteitswaarde --> values about the measurements


So as I see it:
machine has machineparts and machineparts has related measurements.
for each product that is made on a machine the mesurements has to be registrated according the frequentie.

If it is helpfull, i have a database filled with data and forms, maybe than it is more clear but i can't send it as attachement in the forum because of the size.


Thanks in advance,
Sven.
 
Creating Relationships - "TblKwaliteigegevens" table

I'll look at the tables post my remarks as I finish.

First, in the "TblKwaliteigegevens" table, the Field "CatagoriesID" serves no purpose. It isn't tied to another table that defines it or limits the possible entries. As it currently stands now, a user will be able to enter any number they want and the database will accept it. I've always held that a Key field should have a defined entry limited by a table when possible. In my opinion, this make for cleaner data and reduces problems in the future.

You either need to create another table and set the relationship between it and this field or remove this field. (Also, the same field is used in the "TbleMachineonderdeel" and it is auto generated. This could lead to a little confusion down the road so consider changing the name in one of the tables.) The table would have two fields, "CatagoriesID" - Autogenerated Number and "CatagoriesName" - Indexed - Yes (No Duplicates). Additions to this table would be limited to key personnedl to ensure quality of the entries. Plus, it is easier to understand a "Name" than just a "Number".

Also, the "KwaliteitID" field should be changed to Indexed - Yes (No Duplicates)

Finally, what exactly makes a record in this table unique? To me it would seem that these fields would make each record unique are the MachineID, Kwaliteitsnaam, and CategorieID. The "KwaliteitID" field number isn't unique it's autogenerated and really has no meaning and could really be dropped.
 
Last edited:
Creating Relationships - "TblFrequentie" table

I would change the Key from the "FrequentieID" field to the "Frequentie" field and make the "Frequentie" field unique and required. It's not the number of the "FrequentieID" field that is unique (Indexed - Yes (No Duplicates)), its the "Name" defining the "Frequentie" that is unique. The "FrequentieID" is random and holds no meaning except to tie the two tables together. (Again, number have little meaning, words do!) However, you need to change the 'FrequentieID" field to be a Indexed - Yes (No Duplicates) field.

Again, because it is a "Defining" table, I would limit who can enter data into this table.

Also in the "TblKwaliteigegevens" table, change the "FrequentieID" field to Indexed - Yes (Duplicates OK).
 
Last edited:
Creating Relationships - "TblKwaliteitgegevens" table

Is the "TblKwaliteitgegevens" the table that defines the "CatagoriesID" field in the "TblKwaliteigegevens" table? Are these Definitions unique to a Machine? Or are they definitions for the "CatagoriesID" for all machines? If they are for all machines, you need to remove the "MachineID" from this table and then set the relationship between it and the "TblKwaliteitgegevens" table.

If this is true, you also need to change the fields as follows: CategorieID - Indexed - Yes (No Duplicates) and the Categorie - Indexed - Yes (No Duplicates). Then set the "Categorie" field as the Key field.
 
I have changed my relationships but it is still not working. When I run a query with a conection between tblkwaliteitswaarde - tbl machine - tbl kwaliteitsgegevens the records are multiplied with a factor x.
What kind of query were you running? What did it look like? Were there calculations involved? That might be the only reason you got that multiplication factor in there.
 
Creating Relationships Sample of table changes

Here is my change to the table structure
 

Attachments

Users who are viewing this thread

Back
Top Bottom