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
0
votes
2 answers

Best practice for RESTful API design updating 1/many-to-many relationship?

Suppose I have a recipe page where the recipe can have a number of ingredients associated with it. Users can edit the ingredients list and update/save the recipe. In the database there are these tables: recipes table, ingredients table,…
rahc01
  • 47
  • 7
0
votes
1 answer

What is the best way to manage a junction table? (delete and insert)

I have two tables Users and Permissions, and a junction table UserPermissions like this (these tables are examples) : CREATE TABLE Users ( UserLogin varchar(50) PRIMARY KEY, UserPassword varchar(50) NOT NULL, UserName varchar(50) NOT…
Rocstar
  • 1,427
  • 3
  • 23
  • 41
0
votes
1 answer

How to merge rows on a table and update junction table on postgres

Consider 2 tables (table A and table B) with a many-to-many relationship, each containing a primary key and other attributes. To map this relation there's a third joint table (table C) containing the foreign keys for each table of the relation (…
GRoutar
  • 1,311
  • 1
  • 15
  • 38
0
votes
1 answer

Confused about junction table implementation

First things first, I'm not a programmer and this is the first time I've worked with database creation and this implementation is part of a need that was identified during the internship that I'm currently doing. I'm currently developing an MS…
Javier 82
  • 3
  • 2
0
votes
2 answers

PostgreSQL. Update junction table

I want to update my junction table's row. Not literally update, insert only new tuples and drop the ones that were not inserted. Here's my tables: users table ----------------------- |user_id |FullName | ----------------------- |1 | John …
Nikita Kalugin
  • 682
  • 2
  • 14
  • 37
0
votes
1 answer

PostgreSQL. Insert valuse in junction table

Good day. I'm having some trouble with insert data in junction table. Here's my tables: users table ----------------------- |user_id |FullName | ----------------------- |1 | John | |2 | Michael | |3 |…
Nikita Kalugin
  • 682
  • 2
  • 14
  • 37
0
votes
0 answers

Query with two group by and a count on a basic tri-table many to many schema

Here is the DB Schema I am using (Many to Many relationship between clients and products via junction table client_product): TABLE client - clientid - clientname TABLE product - productid - productname - category TABLE client_product - clientid* -…
Manu1583
  • 1
  • 3
0
votes
1 answer

Stored procedure insert into junction table

Table #1: Messages (PK_ID, Subject, Message) Table #2: Messages2Members (FK_MessageID, AuthorID, RecipientID) To handle multiple message recipients (i.e. CC's) my stored procedure first inserts into tbl.Messages, but to insert into…
M S
  • 7
  • 3
0
votes
1 answer

How to create a junction table and add index?

Below is my code for creating my two tables, and since playlist and song are many-to-many relationships, I go ahead and create a junction table... CREATE TABLE Playlist ( Id VARCHAR(20), [Name] VARCHAR(50), Create_Date DATE, Username…
Chloe
  • 55
  • 7
0
votes
1 answer

mysql - How to perform joining of of two junctional tables in case where one of them has foreign key of another?

I am new in the database design, so I am still learning, so sorry for maybe inappropriate terms using, so I will try to explain on common language what problem I have. I learned how to join two tables (getting result) over junction table which is in…
0
votes
1 answer

Mysql groupBy similar products based on relationship if there is any

How can I groupBy product_id a query on transactions but I need the products with options to be shown separately. For example in the table transactions if I have: ProductID Quantity Price 1 1 10 1 1 10 1 1 …
Victordb
  • 519
  • 1
  • 11
  • 25
0
votes
2 answers

Insert all records into junction table in Symfony

I have a next tables: quiz, question, and question_quiz. I have a many-to-many relationship. Insertion work right for table quiz and question, but in table question_quiz inserted only single record. My tables "question", it's all…
JustName
  • 111
  • 4
  • 11
0
votes
0 answers

Insert into junction table with relationship many to many in symfony 4

I have a next tables: quiz, question and junction table question_quiz. I have a many-to-many relationship. Insert is working for the tables quiz and questions but I don't understand how insert in junction table. Entity quiz. class Quiz { /** …
JustName
  • 111
  • 4
  • 11
0
votes
1 answer

Entity Framework Code First: multiple one to many

I'm using EF Code first and want to create such structure for example: There is "Invoice" model And also we have other entities like Client, Customer, etc that may have a list of Invoices basically the relation is one to many. One invoice can…
Corina
  • 1
0
votes
2 answers

Junction table in yii php

I would like to create a junction table tbl_guid_cost_centre that gets taken care of without me manually saving it to the database. I tried adding this to my relations: 'costCentre' => [ self::HAS_ONE, 'CostCentre', …
Nicky Mirfallah
  • 1,004
  • 4
  • 16
  • 38