473,396 Members | 2,024 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,396 software developers and data experts.

table composite primary key and one to many relationship

Hi.

I have a junction table with a composite primary key (ie. two field are used to define the primary key). I need link a third table to the junction table in a one to many relationship. In the attached photo relation_probleme.jpg, the table without any relations should be on the "many" side and the junction table on the "one" side.



The idea is that there are a many "elements" elements linked to many "inspections" and vica-versa. for each pair element-inspection i want to attribute a "condition", in turn this one "conditon" can be linked to many "recommandations".

I have considered using a single field primary key in the junction table called id_cond, but I don't want to do it like this because i don't want to the possibility of an element being attributed multiple conditions for the same inspection.

So how do I do it?
May 10 '12 #1
3 10969
NeoPa
32,556 Expert Mod 16PB
You can link [tbl_cond_recommand] by adding both fields of the composite PK of [tbl_condition_ele] to it.

However, you can also assign a single-field, unique PK to [tbl_condition_ele] if you choose (and there are reasons why it would be advisable). Having a PK doesn't stop any other indices from being set up as mandatorily unique.
May 10 '12 #2
Hello. Thank you for the info about being able to have unique indices that aren't primary keys. I used it in a slightly different way than you suggested. I made a triple field primary key and made one of those fields unique (Noname.jpg). Does anyone have any feed-back about which of the solutions presented is best, and why?

May 11 '12 #3
NeoPa
32,556 Expert Mod 16PB
That's not a good idea Emily. Never make an index more than it needs to be. [id_cond] can (should) be the PK and a compound index including [id_element] & [id_inspec] can be set up as unique. What more you may need/require is down to what you require the design to do for you.
May 11 '12 #4

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

Similar topics

9
by: Bob C. | last post by:
I want to create a 1-many relationship. Parent table has a primary key, child table has no primary key. The child table does have an index with all four fields of the parent's PK. How can I do...
1
by: Johnny Meredith | last post by:
Hi, I'm building a database that, once a year, generates surveys that are emailed to people in our organization. The recipients of the surveys are managers of various departments. The emails...
3
by: lorirobn | last post by:
Hello, I have a report which uses a subreport. When I run the report, I get "Enter Parameter Value" error message for "tblGuestRoom". I click ok and the report seems to work fine. I...
18
by: Thomas A. Anderson | last post by:
I am a bit confused in creating a composite primary key. I have three table with two of the tables containing primary keys. I have two of the tables (each with a primary key) having one to many...
0
by: bvdrsganesh1981 | last post by:
Hi All There are 2 Tables: Tables are : Tbl1 ( 1col1,1col2,1col3,1col4) and Tbl2 ( 2col1,2col2,2col3) In Tbl1 (1col1,1col2,1col3 ) are composite primary key.So...
11
by: RobertJohn | last post by:
Hi all I am using Access 2007 to start a small home library application, and so far it has two tables. 1. Books, with fields Book_ID (Primary Key) and Title, and 2. Authors, with fields...
6
by: BD | last post by:
Hi, all. I need to enforce a one-to-many relationship on 2 tables, with a join table. Say the join table contains account information. It has cust_no and acct_no. Both cust_no and acct_no are...
6
by: NicoleCartrette | last post by:
Going back to school is easier said than done.. This was posted to an older thread earlier but I don't think it got any attention. Your help is appreciated Professor requires we create a...
2
by: chrisbo | last post by:
I have three tables and want to create a many-to-many relationship between them. The main table has a composite primary key http://www9.vgregion.se/vastarvet/va/bilder/db_photo.jpg This can't...
1
by: Madhususdhan | last post by:
Hellow, I am new to MS SQL Server and I have been designing a database for my company. I am using Microsoft Visio for desigin and in my database design, I am planning to use composite primary key for...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.