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
2
votes
1 answer

SQL Junction query with 3 table references

I'm looking to identify from my data input all wine bottles purchased from danmurphys that were produced in 2012. My query syntax isn't right and I'm not sure what I'm doing wrong. Your help would be much appreciated :) CREATE TABLE…
2
votes
1 answer

Junction Table to connect 3 tables?

I'm new in programming and database. Currently working on an inventory project which involves Department (Physics, Chemistry etc), Category (Physics -> Heat, Chemistry -> Organic) and actual Lab Items (Physics -> Heat -> Match Sticks, Chemistry ->…
chrisf
  • 23
  • 2
2
votes
2 answers

Elides junction table, how do I insert a row without querying the database for the entities referenced by the row?

Let's say we have a simple schema: Employee -------- Id EmployeeName Project ------- Id ProjectName EmployeeProject --------------- EmployeeId ProjectId In a previous version of EF, I remember the junction table getting added to the model (or…
Turch
  • 1,546
  • 2
  • 15
  • 31
2
votes
1 answer

discriminator in junction table with Doctrine

I have a number of unrelated entities that I'd like to be able to add FileAttachment entities to. I'm using Doctrine2 (in the context of a Symfony project). Before I started using Doctrine, I'd make a junction table with a discriminator column,…
dnagirl
  • 20,196
  • 13
  • 80
  • 123
2
votes
2 answers

Configure WebSEAL Junction Mapping

Hi I am trying to configure my jmt.conf file.Though i write the junction name in it . When i try to load the table with server task command it gives me couldnot reach to server
Angel1403
  • 145
  • 1
  • 4
  • 13
2
votes
1 answer

php - return multiple values to from mysql

I'm dealing with a junction table for a many to many relationship between products and categories. With this particular function I'm attempting to take in a product_ID variable and get all associated category names in an array. However, with the…
Dustin Maxey
  • 125
  • 1
  • 12
2
votes
1 answer

Displaying information obtained from multiple junction tables with MySQL and PHP

This is for a lesson scheduling app. There is a lessons table (id, start time, end time, etc) which will link via junction tables (via IDs) to a students table (id, first name, last name, etc) and a teachers table (id, first name, last name, etc).…
Guy
  • 876
  • 1
  • 10
  • 28
2
votes
1 answer

information from Junction table combined into one field related to 1 record with a query

I am having difficulty trying to write a query for this example database: 3 tables = Program Code, Work, Work Code. Program Code table has a many to many relationship with the Work table through the Work Code table. Table layout is as follows: Work:…
user2380034
  • 73
  • 1
  • 1
  • 5
2
votes
1 answer

Integrate junction and lookup tables with a basic Access database

I have a simple database that stores a customer's name, city and state. I've added to this two new tables. One is a lookup table, for describing a car model, and the second is a junction table for setting up one or more car models with a customer…
a coder
  • 7,530
  • 20
  • 84
  • 131
1
vote
2 answers

Pros and cons of a junction table between three tables, only two of which at any given time

I am going to be have a many-to-many relationship across three tables, but the relationship will be between only one table (say TableA) and only one of the other two tables (say TableB and TableC) at a time. That is, I can have either one junction…
cm007
  • 1,352
  • 4
  • 20
  • 40
1
vote
2 answers

How to insert variable rows to a Postgres junction table: concatenate a query string or make a many queries or other?

Here is the code: // the JSON of req.body { "title": "title", "reference": "1213", "noteType": "type_1", "tags": [3, 4], // Will be variable length. "text": "Lorem ipsum dolor sit amet." } // Create the row and get the…
STEVE J
  • 21
  • 3
1
vote
2 answers

Relating Tables with no previous Relation (SQL Server)

EDIT: I swapped out my structural implementation, but my problem still remains the same; i.e. First creating a Publication object (if it doesn't yet exist) before creating the SvcRequest record. I was given a database that I had to "fix" and am…
1
vote
0 answers

Spring Boot | How do I update / save extra attributes in a ManyToMany junction table?

So I've been recently creating a ManyToMany Table with custom attributes in Spring Boot. There are the usual 2 foreign keys in it and extra simple attributes as two Longs. The middle table is getting filled as it should, but how do I also…
tstdplt
  • 223
  • 1
  • 8
1
vote
2 answers

Junction table in PostgreSQL

I have two tables recipe table ----------------------- |recipe_id |name | ----------------------- |1 |Pasta | |2 |Pizza | |3 |Fish | ingredient table ------------------------------- |ingredient_id |name …
zupus
  • 79
  • 1
  • 6
1
vote
1 answer

Junction table indexing in many-to-many relationship

Let's say we have a PRODUCT table, ORDER table and a junction table PRODUCT_ORDER. I create a junction table with the following script: CREATE TABLE public."PRODUCT_ORDER" ( product_id bigint NOT NULL, order_id bigint NOT NULL, …
Georgii Lvov
  • 1,771
  • 1
  • 3
  • 17