Join 2 Tables With Composite Keys

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 Replies


ADVERTISEMENT

Bridge Tables W/composite Primary Keys

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

Composite Keys

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

Many To Many And Composite Keys

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

Composite Keys Possible?

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

Composite Primary Keys

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

Composite Primary Keys

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

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 5 Replies View Related

Create A JOIN Of Different Tables Called Join A Variable And List

Nov 16, 2013

And then called this join as a symbol or variable, and then have it use to select the items from these joined tables, can this be done in Access? Here is an example of a code that I created, but it has an error message saying the FROM syntax is incorrect.

Code:
SELECT firstJOIN.trainID, firstJOIN.trainName, firstJOIN.stationID, firstJOIN.stationName, firstJOIN.distance_miles, firstJOIN.time_mins
FROM (trains INNER JOIN ((station INNER JOIN lineStation ON station.stationID = lineStation.stationID)
INNER JOIN bookingLeg ON bookingLeg.startID = station.stationID or bookingLeg.endID = station.stationID )
ON trains.trainID = bookingLeg.tid) as firstJOIN

Can Access do something similar to this, in the FROM statement I joined 4 tables, because each unique fields are in each table and I have to joined them to get those fields. I called this join firstJOIN and in the SELECT statement, I list those columns in the table by calling it firstJOIN.trainID. Can Access do something like this, but syntax it differently?

View 6 Replies View Related

Tables :: Composite Primary Key

Jun 2, 2013

Composite Primary Key in Ms Access 2010. I shall try and explain my tables in detail. So my first table is "Client Database" where the field "Buyer" is primary key. This is connected to my next table "Project Database" which has fields such as Work Order #, PO #, PO Date , Buyer etc where Work Order # is the primary key. Finally "Projects Database" is connected to Order information. Now the problem is until now, I always had 1 PO # for each Work Order #. However now I am facing a situation where my client has clubbed multiple PO #'s for the same Work Order #. I need to trigger the Primary Key Violation only if both the Work Order # and the PO # are the same.

View 8 Replies View Related

Junction Tables Has Composite Key With Two Fields

Jun 17, 2015

I have an events table and a junction table that has a composite key with two fields; those are the only fields on the junction table and are FKs in my events table.

I have a form that fills in events to my events table and also fills in values to my junction table. The control source is a query of the two tables along with a couple of other reference tables for metadata associations. The form works fine... the first time. My problem is that, after I have entered an event that has my unique composite key for the first time (thereby entering a new record to my junction table), once I go to enter a second event that uses the same key, access tries to enter the record again and throwing a "3164: field cannot be updated" error instead of referencing the already created composite key.

I have the form set the composite values to the selected values on form load. Normally, I would just set the primary key to the primary key values and access would follow my logic, but in this case it always tries to make a new record.

View 5 Replies View Related

Tables :: Auto-increment Part Of A Composite Key

Oct 17, 2014

My table key looks like this. Its a table that keeps a master record of conferences that occur during a calendar year

ConfYear (Date/Time) primary key
ConfNo (Byte) primary key

As you see its a composite key. Now each time a new record is created i want the ConfNo to autoincrement within its ConfYear. I used a byte as its not usually more than 4. Autonumber does not work as part of a composite key i found out.

2014 1
2014 2
2014 3 etc

And revert to 1 when ConfYear input changes to 2015

Is there a simple way to do this with say, a macro, or is the only way with VBA and DAO?

View 12 Replies View Related

Tables :: Change Record That Is Part Of Composite Key?

Feb 26, 2015

I am creating a database that tracks the selling of products amongst other things.

The user will enter in an order and may delay invoicing until the customer approves the quote - at which time the order is turned into an invoice.

In the transactions table the OrderID, ProductID and CustomerID constitute a composite key.

I want to be able to view the order and change it by either deleting or adding ordered items (obviously prior to invoicing) but because the ProductID is part of the composite key I cannot delete a line item.

Perhaps the solution is to remove ProductID from the index or is there a better way?

View 8 Replies View Related

Foreign Keys And Tables

Sep 25, 2006

hi
i need to create a table, i've figured out to make LastName the primary key. But im not so sure about the foreign key, and whether it is necessary to put it into the table in order for all my tables to relate? Sorry if this doesn't make much sense.
Also, to clarify.. 3NF primary keys in one table cannot be used in another table??
thanks

View 2 Replies View Related

Updating Tables With Missing Keys

Jul 25, 2005

Hello,

I'm designing a database that is used both in the office and field and it has two tables - an "office" table and a "field" table. The office table is a list of addresses, cities, and counties, each with a custom-designed key field. The field table contains equipment information at each location specified in the office table.

What I want to do is set up the database so that field personnel can copy an updated office table (with new locations added or old locations removed) into their databse and click something and have the tables "resync" with each other - the field table automatically adding new records to match those in the office table or delete records it has that it doesn't find in the office table...

Any thoughts or helpful links?

View 5 Replies View Related

Merging Tables With Unmatched Keys

Nov 12, 2007

Hi all, im hoping someone can help. This is the problem.

I have 3 tables that have tax payer information for 1 year broken up into 4 months, 1 table for each 4 month chunk. all 3 tables mostly have the same taxpayers, but each table has payers that are not in 1 or both of the other tables. each table has a 2 part primary key, the business number is the first part, and branch number for businesses with chains. the next 4 fields are each month of taxes paid. heres the design of each table.

Q1
ID 1ID2Data1 Data2 Data3
10
20
31
40
50

Q2
ID1ID2Data1 Data2 Data3
20
40
61
81
Q3
31Data1 Data2 Data3
40
61
81
90
100

is there an easy way to merge all of this data into 1 table easily. ive tried using make table or append queries, but it only addes the information where the IDs are in each table. this leaves out the ids that are in only 1 or 2 tables.

if you need me to clarify or explain anything else, please let me know. i can post screenies or the design, but obviously, not the data.

View 4 Replies View Related

Tables :: Two Primary Keys Link To Another Table?

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

Tables :: Use Of Standard Access IDs As Primary Keys

Feb 12, 2014

I've built a system with around 20 tables in it. All of these use the standard ID field offered by default by Access as the primary key. A friend with a background in database design and development for large corporates using Oracle has reviewed the database (he is going to do some VBA programming for me) and suggested that we use more appropriate primary keys based on data attributes.

He has read "somewhere" that there are problems with the standard ID fields and that occasionally the fields are renumbered/reindexed and that this can cause problems. There are a fair number of queries and some complex forms which will need to be updated for these changes but it would be a shame to go through all this work if it isn't really.

Should we use the standard Access IDs and is it worth a chunk of effort to change from where we are now?

View 6 Replies View Related

One Primary Key In One Table Linked To Two Foreign Keys In Two Different Tables!!!

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

Tables :: Inserting Foreign Keys Within A Text Field?

Aug 28, 2013

I've got a table - "Products" - in my database, with a text field - "Info" - which contains info about products.

Within this field I would like to have footnotes. To do this, I think the best way to do it is by putting numbers inside the text at the location of where I want the footnote to refer to. These numbers will actually be foreign keys to a table called 'Footnotes'.

I can then program the forms and reports to show any numbers as superscripts or whatever.

(Of course, if the user will actually want to insert a number into the text field which is NOT a reference to a footnote, I will have to make a workaround e.g. by making access put a symbol in front of the number, so access will know the number is just part of the text (and I will program the form to not show the symbol in front of the number)).

Is it wrong to have foreign keys within a text field? I think if executed correctly, it should work perfectly.

View 8 Replies View Related

Tables :: One Primary Key To Multiple Foreign Keys In The Same Table?

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

Tables :: Setting Primary Keys To More Than One Field In Table / But They Cannot Have Null Values

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

Join Tables SQL = Problem = My Tables Are Not Normalized

Dec 15, 2005

Okay - the other database is in the works and is going sloooow (the one that is being created with normalization).

Meanwhile, my other database that has no normalization I am having a problem running a query (now I know why its so important to have good structure).

To give you an idea on how bad this is...:o .....

3 tables - 94 fields to each table - each table has identicle fields, just different data. :eek:

Anyways, I have students in each table (each table is an Annual Report). I want to be able to run a simple query and combine all the students into one.

How would I achieve this?

Thank you!

And for all who are thinking about designing a database - READ READ READ and do some more reading on normalization!!!

View 3 Replies View Related

How To Join 3 Tables?

Feb 25, 2005

helooo...

i have 3 tables -Recipes, Ingredients and Products.

Recipes table:
RecipeID -PK

Ingredients table:
IngredientID -PK
IngreRecipeID -Foreign key to Recipes table
IngreProductID -Foreign key to Products table

Table:
ProductID -PK

how do i join them into 1 recordset? :confused:

View 1 Replies View Related

Join Tables

Jul 11, 2005

HELP!!! :confused: I do have a 5 tables 4 tables do have a foreign key of the main table. I join the 4 tables with the main table but when I am editing the information I cannot edit it. and no error appears. so I am just wondering what happen with my joined tables? please help me!!!!Thank you in advance

View 1 Replies View Related

Join Tables

Apr 3, 2006

How do I join two tables. I have a table and a lookup table. My table has products on there that are listed as custom or basic. I have a look up table that has an ID for basic and Custom. In my table, i want it to read what the id is for each product instead of it reading "basic" or custom. Someone said that I need to join the two tables and do an update query, but I don't understand how to.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved