Questions tagged [junction-table]

A junction table is a table that contains common fields from two or more tables and is the canonical way to implement Many-to-Many relations in SQL and Relational-type databases.

In database management systems following the relational model, a junction table is a table that contains common fields from two or more tables. It is on the many side of a one-to-many relationship with each of the other tables. Junction tables are known under many names such as bridge table and linking table.

221 questions
1
vote
1 answer

Three-way Junction Table OK? or is it an entity?

Is a Junction Table with three Primary/Foreign Keys allowable? Or does does my original Junction Table linking just two Tables become an entity when I add the third primary/Foreign key. I need to know whether it's an entity or a three way Junction…
COOLBEANS
  • 729
  • 3
  • 13
  • 31
1
vote
0 answers

Relational Database: Is junction table with a third foreign key still a junction table.. or entity?

I have a junction table (Actor_Character) with a composite key made from the primary keys of two other tables (Actor & Character). Because it's a junction table Actor and Character will also both be foreign keys. Now, if I add a third foreign key…
COOLBEANS
  • 729
  • 3
  • 13
  • 31
1
vote
2 answers

Zend_db junction table join query

Not sure why I can't figure this one out. Basically, I have two tables with a many-to-many relationship so I have a junction table inbetween them. For an example, consider the following database schema: Restaurant (id, restaurant_name,…
user43040
1
vote
2 answers

SQL n:n - best practice for queries in junction table

I'm aware there are many question already started for SQL n:n queries. However I could'nt find a solution for my problem. I would like to create a project which is something like a personal thesaurus. In it, the user can define which word is related…
mdthh
  • 1,248
  • 1
  • 13
  • 22
1
vote
1 answer

DataBase Analysis-junction table

This matter confuses me, I have a College Information system the junction table between students table and subjects(curriculum) table, the primary key is composite key (StudentID, SubjectID) and both of them are Foreign keys but the student may be…
1
vote
5 answers

SQL select to eliminate duplicate value that has 2 other values in next column

I have constructed a junction table which goes like this. Table Name: myTable p_id | c_id ----------- 1 1 1 2 1 3 2 2 2 3 3 2 3 3 3 4 I wanted to SELECT p_id that doesn't have both c_id 3 and 4. In this case only…
caramel1995
  • 2,968
  • 10
  • 44
  • 57
1
vote
2 answers

Delete row from Access junction table via form

I set up a subform listing stored values from a junction and lookup table. This part is working nicely (I can view all stored entries or add new ones). Here are my relationships: And here's the layout of my form showing where I attempted to…
a coder
  • 7,530
  • 20
  • 84
  • 131
1
vote
2 answers

Automatically delete junction data along with DELETE of a record?

I have users, have offers, and a junction table users_offers. Is there a setup I can carry out with foreign key relations that can ensure that junction data will be automatically deleted when I delete any users or offers?
Geri Borbás
  • 15,810
  • 18
  • 109
  • 172
1
vote
1 answer

Maintaining rows in a SQL Server junction table when rows in other table are inserted and updated

Can you show sample coding to create a trigger or stored procedure that maintains rows a SQL Server junction table when changes are made to the Authors and BookTitles tables such as inserting and updating rows in those tables? We have the following…
Emad-ud-deen
  • 4,734
  • 21
  • 87
  • 152
1
vote
3 answers

Help required to optimize LINQ query

I am looking to optimize my LINQ query because although it works right, the SQL it generates is convoluted and inefficient... Basically, I am looking to select customers (as CustomerDisplay objects) who ordered the required product (reqdProdId), and…
Ra.
  • 289
  • 1
  • 3
  • 16
1
vote
2 answers

Insert into bridge table entity framework

Hi guys, I'm learning to climb with EF ,I do have basic understanding of CRUD with EF ,but now I have a table which have a navigation property (Which I suspect is the bridge table) ,so I need to add value into the bridge table ,I think I can do it…
1
vote
1 answer

Junction/Bridge tables Oracle SQL

Just a quick question regarding Junction tables in Oracle SQL. I understand their functionality and their role in a 'many to many' relationship but what about a 'one to many' relationship? I have two tables, Employees and Positions. Each Employee…
adohertyd
  • 2,689
  • 19
  • 58
  • 78
1
vote
2 answers

What is the best way to model a heterogenous many-to-many relationship in Django?

I've searched around for a while, but can't seem to find an existing question for this (although it could be an issue of not knowing terminology). I'm new to Django, and have been attempting to take a design which should be very expandable over…
ThreeHams
  • 125
  • 1
  • 7
0
votes
1 answer

Inserting into intersection table referencing foreign key

Prop PropID PropDescription Many to Many relationship Image ImageID ImageDescription Image_has_Prop Prop_PropID Image_ImageID In my application, I need to insert data into the Image_has_Prop . The user types in the ImageId, and then selects the Prop…
Peddler
  • 6,045
  • 4
  • 18
  • 22
0
votes
1 answer

If you do a many to many relationship in a MySQL db is it necessary to transfer all of the key id's to the join table?

So I am working with MySQL workbench 5.2 and i am making an EER diagram for my database, and when I make a many to many relationship between a table (and those tables already have relationships with other tables) it creates a junction table with all…
AlexW.H.B.
  • 1,781
  • 3
  • 25
  • 50