Composite Keys For Table?
May 12, 2005
I need some help with developing a certain aspect of a db. I need to track the equipment list of clinics. The equipment list doesn't really change (it has 5 possible values though each clinic may only have one to all 5 of them). The db is also to track who the manufacturer is.
I was originally going to do a three piece composite key consistenting of the clinic id, the equipment id and the manufacturer id with quantity as the non pk field. Or the other possiblility that I can see is just using an autonumber as the pk with clinic id, equipment id, and manufacturer id as fk's with qty as the non-key field. So what do you think? If you can put in explanation why your suggestion would work, that would be appreciated as I'd like to increase my knowledge base on this stuff.
If I haven't made my problem clear, I'm quite willing to provide more info.
Thanks,
scratch
View Replies
ADVERTISEMENT
Dec 5, 2005
I have recently started a new project, on one of my tables i have a composite key for my primary key. However when i create a relationship using one of the fields in the primary key i can't "enforce referential integrity". Every time i try i get the message "No unique index found for the referenced field of the primary field"
can any one help
Mindy
View 2 Replies
View Related
Oct 6, 2007
Many to Many
I have a basic question, I know for a fact that all many to many relationships have to be broken into two one to many relationships using a junction table. However does that mean it is (a must )to have the two foreign key of the parent tables have to be the (primary composite key) of the junction table.
For example, let’s say I have 5 tables that I need to establish many to many relationships between them. Is it correct to establish a junction table with all 5 foreign keys of the parent tables as composite primary key in the junction table to!
Hope the above making sense!!! :confused:
Many thanks :)
View 3 Replies
View Related
May 13, 2005
Can Access deal with Composite Primary Keys? or will it only let you assign a single attribute key?
If it does allow you to create composite primary keys, how do you go about doing it?
View 1 Replies
View Related
Feb 25, 2005
Is it possible that a composite primary from table A to be a foreign key in table B?
I have two tables: A and B. The A has some personal details such as first name, surname, phone number, etc.
Since no personal ID is given in my project, I am thinking to use first name + surname as the primary key of table A. But when I wanted to make the relationship between A and B (in B I need to use these 2 name fields as the composite primary keys, too) and ticked the option “enforce referential integrity”, an error message prompted out said it could not find the only primary key in table A.
What should I do with this? Or it is impossible to have a composite primary key to be foreign keys (but also primary) in another table?
It will be great if someone could answer this!
Thanks!
View 4 Replies
View Related
May 5, 2005
I've noticed that the great and the good all seem to recommend not using composite PKs. Does that even go for join tables in the middle of a many-to-many relationship? Not sure I see what's to be gained by adding an ID and making that the PK.
Any comments?
Dave
View 14 Replies
View Related
Oct 3, 2007
Hi,
I am trying to join 2 tables with composite keys - each of them have the same 4 columns as part of its key - date/person/problem/date sent.
Table 1 has 5 columns (4 key columns + 1), Table 2 has the same 5 columns plus 1 additional column (Comments).
I am trying to match the Comments column in Table 2 to Table 1 and show the output in another table.
Currently, I've related the 4 columns in each table to each other, each relationship defined as including all records from Table 1 and only the records from Table 2 where the fields are equal.
In the fields, I have 5 Columns from Table 1 and the last column (Comments) from Table 2. When I run the query, I get all the records from Table 1, but not all of the Comments that match from Table 2 are shown.
Any Ideas on how to improve this link?
Thanks!!!
View 7 Replies
View Related
May 17, 2007
I am creating a bridge table to get rid of redundant data. I am doing it by making a composite of the primary keys from the two tables I am bridging.
The error message when I get to a certain point is "You cannot add or change a record because a related record is required in table tblMachCent." Both the numbers I am using to create this composite key are in the tables necessary, so I am not sure why I am getting this problem. Any suggestions??
View 1 Replies
View Related
Oct 9, 2006
I will try to explain my problem.
I have a composite key in my table....(i.e. 2 primary keys), when I do an "update" querry through a form and try to update just one of the primary keys, it adds an entirely new record to the table with the updated primary key field.
What I want to do is to be able to update just one of the pirmary keys in the same record (i.e. without adding a new record)
Is this possible?? How?
View 2 Replies
View Related
May 28, 2015
I have a table for a multiple parents linked to a child table. I need to figure out a way to only allow 1 parent to be coded as primary, 1 as secondary, and then the rest as other... I thought about making Primary/Secondary/Other a primary key. But then I can only have 1 other. I would have to make a finite number of parents that could be entered and I want an infinite number.... My end goal is to have a report that only has a primary and second parent on it, but the rest of the parents still exist in the table...
*Child_ID
Parent_First_Name
*Primary/Secondary/Other
View 8 Replies
View Related
Mar 21, 2013
I am absolutely new to Access. How do I put the primary key from one table into another table?
View 1 Replies
View Related
Apr 20, 2006
I'm not new to access, and I understand normalization at pretty much all its levels, but right now I'm curious about a situation that I have just come across. The first time I've been in something like this, so I thought I would ask.
This is the setup.
I have employees. They are apart of a shift and a budget. Shifts and budgets are completely independent of each other.
The database needs to keep track of shifts and budgets over time. Therefore, 1 to many relationship to shift table and budget table.
But, the database also needs to keep track of attendance. And the user wants attendance tracked by Shift and Budget.
Shift and budget are completely independent of each other.
Currently, I have the relationships set up like this.
Employee (1) ---(Many) Budget (1)------(Many) Attendance
Employee (1) ---(Many) Shift (1)--------(Many) Attendance
When a new attendance record needs to be added, both the key to the budget and shift are added to the attendance table. The key chosen is dependant onthe Employee chosen, and whether the budget and shift are the CURRENT budget and shift that the employee is apart of.
I thought of running a query showing budget and shift by date descending, so that the latest budget / shift would be displayed, and thus the most current (SUPPOSEDLY) But, if a user put in a different date, or screwed up on the date, then the incorrect shift and/or budget would be displayed.
Date stamping an entry was an option, but there needed to also be a user entered date as well, to specify WHEN a user began working in that specific budget / shift. Therefore two date entries would be required. Duplicate entries in most cases.
I therefore decided to go with a true/false yes/no checkbox. Where the current budget or shift would be checked, and all non current ones would be unchecked (false).
Currently, this is how the systems works. And it works well. But it is dependent on some form code I created to set the yes/no checkbox to true/false depending on the situation.
I DON"T like doing this. Am I missing a way to do this "correctly" where by Access would do this "automagically" instead of via my trick.
The ONLY issue really, is that when a new attendance incident occurs, the user needs to put in the incident to the approbriate shift / budget. And if the current shift / budget could automatically be displayed without user intervention (IE user has to pick the shift / budget from drop down box after looking up info etc etc) since the current information SHOULD be known.
I've never done a table setup where two foreign keys are the many side of the relationship in a single table.
It is currently working fine, and seems to do well, but I wanted to make sure with others who might have had this experience. And also, any "advice" / "cautions" for this kind of situation so I don't step into it deep and have to fix it later.
View 14 Replies
View Related
Oct 5, 2015
Can a table have two foreign keys?
View 1 Replies
View Related
Aug 18, 2014
So, I have two Primary Keys in my table, how then do I link another tables to it?
tblAdmissions
PatientID Number Primary Key
Visits Number Primary Key
tblRoomPhoneNumbers
PhoneID AutoNumber Primary Key
View 3 Replies
View Related
Jun 13, 2013
I've set up a table with 2 primary keys but it is allowing me to input the same combinations twice!
View 4 Replies
View Related
Sep 22, 2007
Hi there,
I am trying to model my database to create relationships between different tables in my database. During the process of doing so I ended up having one primary key in table A linked with to foreign keys in two different tables ( table B & table C) and both of those two table are junction tables to break out many to many between many other tables
Now for some reason!!! I feel that there is something wrong with my logic mapping and modeling of the relationships between tables due the fact of having one primary key linked to two foreign keys in two different tables :(
Is my intuition is right? should such case be considered as indicative of wrong modeling of relationships between tables in a single database
And if so what is the disadvantages of that link (talking down the road) when the database if fully populated? :confused:
By the way I am new member and new to database, so please take it easy on me :o
Many thanks
View 2 Replies
View Related
Aug 29, 2013
Right now, I have 4 related tables. There's a table with companies, one with people involved with companies, a table linking the two by having foreign keys of the company number and people names, and a table that indicates directors and their alternates.
Since there's a one-to-many relationship for companies/people to company-peopleID (A person can run multiple companies, a company has multiple directors, it's easier this way), a person's name can appear multiple times, as can a company, within that table.
In a company, a director may or may not have 1 and only 1 alternate director to him/herself. So, I thought the easiest way was to put an autonumber in the Company-personID table and have a table (alternates) that had two fields, "alternate" and "director", both using that autonumber to link them. However, it appears as though I can't link the same primary key twice to two foreign keys of the same table.
[URL]
View 3 Replies
View Related
Mar 26, 2013
I'm developing a simple sporting records db. I have a 'Competitor' table listing competitors as follows: CompetitorPK, Name, Division, Club. I have a 'Contest' table listing contests as follows: ContestPK, Competitor1_FK, Competitor2_FK, Winner_FK, Score etc. My question is have I modelled tables correctly i.e. CompetitorPK will appear in three columns of Contest table. How do I define this relationship? What alternative is there to what I have done.I intend to use forms to populate both tables (independantly obviously).
View 4 Replies
View Related
Nov 30, 2012
Access 2010..One organization that we work with provides us with a block of numbers for each of the two types of contract products we order from them; we do order non-contract stuff from them also.The block of numbers are the same (i.e. 20000 to 30000 this year) for each of the two products. This means that each product can have the number 20000, for example. We call this the Tracking Number. If it is one of these products, we need to select the Contract Number.
For all other one off orders we have with them, we assign our own Tracking Number starting with 00001. This Tracking Number cannot duplicate unless it is one of the aforementioned two products.Both the Tracking Number and Contract Number are in the same table. The user selects the Contract Number from a form (connected to the Contract Number table that has all the details on the contract) and the Contract Number is populated in the same table that has the Tracking Number.Each order must have a Tracking Number (no null)..Not all orders need a Contract Number (null okay).The Tracking Number and Contract Number combination cannot duplicate.I tried setting the primary keys to more than one field in the table, but they cannot have null values.
If not... I have been working on Plan B.... an AfterUpdate on the form (either the form or a field... don't know yet) that looks at a query that only has results if there are duplicate values.
View 1 Replies
View Related
Jan 23, 2006
hello
how can i create compostie keys in access???
also how would validation rule for a text box which would allow a user to enter a date which between a certain range in relation to today's date. eg the date entered cannot be more than one week greater than the current date. i knew who i could do it using VBA but i want to know how to do to using the regular access features.
thanks you :)
View 7 Replies
View Related
Mar 10, 2007
Hi, I am in a great hurry and I need someone to help me as soon as possible. Basically, I have a table called Column, which contains 4 fields:
Column (autonumber, primary key)
Column Description (text)
Rack (number)
Rack Description (text)
There are around 30 columns, and each column has 3 racks. There are different racks for different columns, so the rack description will be different. That is why Rack and Rack Description must be in the same table as column.
The problem is that I cannot make the table have one column with three different racks. I thought perhaps the solution would be to make a composite key, where with Column and Rack, we would be able to identify everything else in the table. But the problem is that I do not know how to create this composite key. Please help me with this. I really need to get this done as soon as possible.
Thanx in advance
View 2 Replies
View Related
Mar 5, 2007
16593
I have attached the above relationship diagram as I am having a few problems with a table that uses composite keys to link to 2 other tables. The table is called subsmag and contains the fields subid and magid to link to the subscriptions (subid) and magazine (magid) tables. Basically 1 subscription can have many magazines and I am using the subsmag table to link the 2 tables. When I try to enter data in a form it doesn't like the composite key. Can anyone help, I have inherited the database design and I'm thinking it needs a redesign.
thanks
View 2 Replies
View Related
Aug 10, 2007
Is it best to have one PK in a table and that as an autonumber?
If so, why do people create composite PK's. Examples please.
View 3 Replies
View Related
Dec 9, 2004
Before I start, I know there is much about "Cascading Combos" in the forums, but I'd rather not go that way.
I have a table of Servers (only field is Server ID) and a table of Domains (Server ID, Domain ID). This is one-to-many, as each server will have multiple domains within it.
I also have a table of Applications which has as part of its primary key Server ID and Domain ID (i.e. that's where the app is installed).
I have used the Lookup tab in table design to easily provide a drop-down list of Server IDs for any new Application record, coming straight from the Servers table.
I want to (simply) add a drop down to the Domain ID field to select Domain IDs that are defined *for the entered Server ID*.
I already have the referential integrity enforced, but would like this simple aid as there are heaps of Servers and lots of similarly named Domains. It's looking to me like this is not possible, as the nub of the issue is how to qualify the Server ID field in the new record i.e.
SELECT [Domain ID] FROM Domains WHERE Domains.[Server ID] = <current record>.[Server ID]
How to define <current record>?
I know some will say forms are the tool for this job, but I need to see lots of records at once as I am entering (or changing) data.
I may be hoping against hope that this lookup capability can cope with a simple composite key.
View 4 Replies
View Related
Sep 9, 2005
I have a rather interesting situation involving creating a primary key. Basically I have two tables.
Table 1
Date, Customer, Part Number, Work Order, Qty tested, qty failed, tech name
Table 2
Defect, reference, quantity(defect), defect cause, part number, work order
The ideal relationship I want to create is that for every Table 1 there are multiple table 2. Regular one to many relationship. The problem is that in the first table it is possible and probable that there will be duplicate records because of the process. The test parts by individual carts, but often they're exactly the same parts with same work orders and same everything else. How should I go about doing this. I don't want to just create an autonumber for each record if possible. Any suggestions?
View 1 Replies
View Related
Aug 29, 2006
Hi
I have a table Orders with fields InvoiceNo And Invoice Series.
I want if of course anyone can help me to Validate the next Invoice Number Not To Be Dublicate and to automatically Increment. Meaning that if Last Invoice number was 45 and Invoice Series is A the next to be A 46. If Last Invoice without Series is 40 the next to be 41, and so on. I can manage to increment the values in one field Invoice number but I can not incoporate the Invoice Series.
Any help would appreciated.
Note : I'm not good in VB so please be kind to me.
Kind regards
John
View 5 Replies
View Related