trying to link the tables 'costume item' and 'JT3 costume items to students', via the fields 'costume item ID'
Zoe, I have included just the relevant bits of the relationship diagram as a quick point of reference.
The problems are as follows:
1. Master Table has PF manually set
The Master Table (costume item) has a Primary Key set, but you are expecting to manually input a unique value in here. By manually I imply that
you will take responsibility for how this record is uniquely identified instead of letting the DBMS do this.
The problem here is that your DBMS (Access in this case) knows that it needs to relinquish control to you from the first record that you create onwards. Now, since this is a
MASTER table, ie no children records in linked tables can be created without there being a record in this table, it means that your DBMS has to relinquish control over how you are going to enforce referential integrity from this point on.
Not exactly what you had intended, but this is the effect of specifying to the DBMS that you will control the identity of the Master table.
You could have gotten away with this if you had to link this to a unique single column/field in the child table, but this is where the second problem raises its ugly little head.
2. Incorrect Unique Identifier in Child Table
The Child/Linked table (JT3 costume items to students) is obviously a "mapping" or FACT table that contains references to at least 4 other tables that unique identifies a specific fact about a given transaction.
In this table you are wanting to keep track of several events that would under other circumstances represent a many-to-many relationship. What this table is doing is keeping track of a given situation where a given
student has been issued with a given
costume of a given
costumer type for a given
dance.
You are not keeping track of a couple of other key values that would uniquely identify this specific transaction. Questions like:
- When did this specific event occur? Shouldn't you have some date related data here?
- Is the costume returned yet? Shouldn't you have a Yes/No RETURNED field in here?
- What was the cost of this transaction and has a deposited been taken for this?
There are probably other thoughts that could also have been captured into this table. By the same token, keeping track of the
costumer typeis maybe not necessary here since you can get that information from the
Costume Item table, unless you are thinking that some constumes, for a given transaction may be registered as a different costume type?
The reason for these observations is simply that the set of columns together will uniquely identify this record, but there is no need to hold all of the fields together as a primary key. It is far more efficient to allow your DBMS to create the unique identifier on the fly than to undertake this responsibility yourself.
This is obviously something that you had realised, hence the creation of the
AUTONUMBER column in the child table and some of these tracking questions in the Master table.
The problem is that this table needed its own Unique Identifier column, which is set as the PK and it needed to be an autonumber field. The Costume ID should then have been drawn down from the Costumer Item table, where it would originally have been created.
The question you should be constantly asking yourself when designing the solution is:
- What does a Costumer Type have a lot of?
- A: Costumes. There you have a Costumer Type table which will have a PK with an Autonum field. The same field will be reflected in a Costume table as a field type of number.
- The Costume table will now also have its own PK field that is an Autonum type of field.
- What does a Costume have a lot of?
- A: A lot of transactions that reflect when it was taken out, how much was paid and whether or not a deposit was taken - hence your JT3 table that would have its own PK/Autonum field plus a field called CostumeID that points back at the Costume table and is a Number type of field.
You have to follow through on that thought process throughout your design.
I have amended portion of you design for the sake of clarity and uploaded an image of the end result here also for you convenience.
Hope this helps...