Skip to main content

Questions tagged [many-to-many]

The tag has no usage guidance.

42 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
4 votes
0 answers
2k views

Postgres: Arrays instead of intermediate tables for many-to-many relations

I have a PostgreSQL 9.3.7 database scheme representing a directed graph of vertices and edges with some many-to-many relations. I'm only ever interested in getting all vertices that a given vertex ...
sudo's user avatar
  • 1,011
3 votes
0 answers
197 views

How to design a database for my entity-relationship diagram about Projects, Tasks and Developers

I'm new to database and my entity-relationship diagram is as follows: According to that I designed my SQL-DDL database statements as shown below: CREATE TABLE Developer ( DeveloperID int NOT ...
Gamma's user avatar
  • 131
2 votes
0 answers
129 views

Resolving a double many-to-many relationship

I have the following database design between entities. A Student can belong to many Departments and a Department has many Students. A specific Department has many Courses and one Course can be at ...
jAdex's user avatar
  • 121
2 votes
1 answer
3k views

Creating a database for a scenario involving students, teachers and courses

I am undertaking a project that involves a student management system, but I am struggling to normalise/create relationships between certain tables. Here is my current setup: Models Users(id, first ...
buzzysin's user avatar
  • 121
1 vote
0 answers
26 views

Search for a record which has an exact set of many-to-many related records

I have a straightforward many-many arrangement: scans id 1 2 products id 1 2 3 product_scan: scan_id product_id 1 1 1 2 2 1 2 2 2 3 When I'm about to create a new scan entry with a ...
Synchro's user avatar
  • 261
1 vote
2 answers
444 views

Design many-to-many join table with additional column

I have product and documentation tables and want to hava a many-to-many relationship between them with an additional condition. The tables look like this: create table product ( id bigserial primary ...
abobov's user avatar
  • 11
1 vote
0 answers
37 views

How to represent arbitrary logical expressions in a many to many relationship?

I have a Course entity in my database and I want to represent its prerequisites. A Course can have many prerequisites. A Course can be a prerequisite for many other Courses Clearly, this would be ...
devordem's user avatar
1 vote
0 answers
342 views

Many to Many triangle between three tables

I am having three entities: Student, Group, Class. All of them have many-to-many relationship: One student can attend many classes, and many classes may be assigned to one user. One student can be a ...
Yolomiys's user avatar
1 vote
1 answer
779 views

Triggers: counting rows in a bridge table after INSERT

I'm using a trigger in order to make a Statistic Table. I have this many-to-many relationship where I have an Order that can have multiple Product's and viceversa. So after an INSERT on Order, using ...
Filippo Scaramuzza's user avatar
1 vote
0 answers
1k views

Many to many relationship, select rows based on values in list

I want to select group_runs based on a list of group_runners.player and I'm having issue getting rid of results that don't have all the values on that list. In this case group_runs with id = 2 shouldn'...
Oen44's user avatar
  • 111
1 vote
0 answers
777 views

Efficiently query product variants from inventory database (avoiding EAV)

I'm building an ecommerce website for fun with three main components: frontend in Angular, MySQL database and a PHP backend that will function as a REST API. The inventory database consists of ...
BobbyTables's user avatar
1 vote
0 answers
412 views

3 table many-to-many relationship

I have 3 table Partcar BarbellWheels Assembly now, im confused how to manage this table to got connection, cause Partcar and Assembly is many-to-many relationship. But, BarbellWheels will merging ...
Ainal Yaqin's user avatar
1 vote
0 answers
430 views

Multiple many-to-many database relations

SO told me to ask here, so this is just copy-pasted from over there We're making a database of anime. Every anime can be listed as having been made by an arbitrary number of studios, and every studio ...
Kahr Kunne's user avatar
1 vote
0 answers
106 views

Reversing many-to-many relationships when transforming data into a galaxy schema

I'm building a galaxy schema for our analytics and sales data from our normalized data tables. I'm unsure how to treat many-to-many relationships in the facts tables. For example, for each sale, we ...
Eran Galperin's user avatar
1 vote
1 answer
89 views

Many-many relation with specific type

Sorry if this question has already been asked, but I didn't find it performing a search. I have 2 tables (table_a and table_b), linked by a many/many relation. The relation can be of two types, ...
darkheir's user avatar
  • 163
1 vote
0 answers
181 views

How to structure Many to Many relationship

I have a customers tables, the customer can be either a company or individual. If the customer is a company, then it has specific structure, that means that each company has a (Director , secretary, ...
user88767's user avatar
1 vote
0 answers
460 views

SQLite insertion with junction table

I need to write a transaction for SQLite, that adds a blog post and links it to content tags, and it seems to be a bit too complicated for me. Here's an example schema: CREATE TABLE blogpost( ...
dba9999's user avatar
  • 11
0 votes
1 answer
30 views

Postgres trigger to update records of several parent tables based on values of a many-to-many join table referencing those parent table records

I have a PostgreSQL 15 join table schema.m2mjointable to link records of several parent tables (schema.table_a, schema.table_b, ...) with other records of those same parent tables: id ref_table ...
s.k's user avatar
  • 372
0 votes
0 answers
27 views

How to do many to many query that returns dynamic number of columns?

I have 2 tables that have a many to many relationship. An items table and a properties table. They are connected by a junction table. Basic versions of the tables below. item_name sword helmet axe ...
Brian Hung's user avatar
0 votes
1 answer
70 views

Process for loading data into a logically-arranged Access database with many-to-many relationships

I'm struggling with the logic and feasibility of a certain workflow. I have a list in Excel containing DatabaseName, TableName, FieldName, SubtypeName, and DomainName. I'd like to select all of the ...
jdawgx's user avatar
  • 1
0 votes
1 answer
97 views

Products multiple variants

My query looks like: select p.id, p.name, vo.value, v.name from products p join products_variant_options pvo on pvo.product_id = p.id join variant_options vo on vo.id = pvo.variant_option_id join ...
kicaj's user avatar
  • 123
0 votes
0 answers
310 views

RBAC Data Model Design

I'm trying to implement roles and permissions for an application I'm working on, from my understanding its an RBAC system. There are Users, Sites, and for each site a user can have different ...
another_one's user avatar
0 votes
1 answer
41 views

Define max number of entities in many-to-many

I want to design a database with a many-to-many relationship with entities students and teams. Each team can have many students and each student can participate in many teams. However each team can ...
User123's user avatar
  • 11
0 votes
0 answers
394 views

Many-to-many relationship vs one-to-many relationships

Recently I read an article about building a tag table for better seraching post by tags. The author suggested using one-to-many relationship with post table -> tag table with tag as text[] type. ...
cozycoder's user avatar
  • 101
0 votes
0 answers
199 views

Constraints on many-to-many relationship

I have a multi-user task tracker. Users are in table user: +---------------+---------+ |user_id(int,PK)|name(str)| +---------------+---------+ |1 |Alice | |2 |Bob | +-...
programagor's user avatar
0 votes
0 answers
46 views

Fetching result from many to many relation tables based on condition

Working on creating a conditional filter query for the following tables. Created a fiddle with data here. Desired output I want to write a single query which first fetches list of all products from ...
coderunner's user avatar
0 votes
0 answers
28 views

Understanding Laravel relationships better

I want to make a simple project to understand better the Laravel database relationships. So I decided to make a movie storage project which is holding some movie names and some informations about that ...
cerealikaeme's user avatar
0 votes
0 answers
31 views

Strategies to get more performance in a specific scenario

Introduction Hi Guys, my name's Joao, i'm currently working as backend and that's my first post. I'll appreciate any help! My team are working on a new feature. During the process of development we ...
João Castro's user avatar
0 votes
0 answers
617 views

MySQL Many to Many with additional data in intermediary table

I need to create a Many to Many relationship and understand the need for an intermediate table to act as the link between the two. The understanding I have is the Group of ID's in the intermediate ...
Michael B.'s user avatar
0 votes
1 answer
2k views

How to Store a Many-to-Many Relationship Between Fact Tables in a Data Warehouse

What are some structures and models to store many-to-many relational data between two fact tables in a data warehouse? Currently, I am using a mapping table which includes the primary keys from both ...
Edward's user avatar
  • 1
0 votes
1 answer
85 views

Why do these queries deadlock and how to work this around in MariaDB?

The following 2 queries enounter DB deadlock in my program: DELETE FROM proxies WHERE NOT EXISTS ( SELECT 1 FROM proxy_xref_proxy_list AS pxpl WHERE pxpl.ProxyID=proxies.ID AND (pxpl....
Serge Rogatch's user avatar
0 votes
0 answers
88 views

Filling a database (from a temporary database) with a Many to Many relation

I have a temporary table that I fill in using a CSV file. CREATE TEMP TABLE temp_products( product_marketplace_name varchar, product_link varchar, product_name varchar, ...
bma's user avatar
  • 21
0 votes
0 answers
197 views

How to handle table that has an id which references multiple dimension tables?

I'm having a hard time figuring out how to create a lookup table or a table that references multiple dimension tables. I've got a "tracking" table that tracks the number of impressions for an e-...
danieltisdale's user avatar
0 votes
0 answers
3k views

Database design for metro train route stations and timing

I am making a city metro train app, and for that, I need some advice from you all experts on how to design a database for the following requirements. The metro has multiple lines (see table), and ...
pixelngrain's user avatar
0 votes
1 answer
606 views

Understanding many-to-many ternary relationship sets

I am new to entity-relationship diagrams. I'm a bit confused when it comes to interpreting ternary relationship sets such as this: Does this signify that every relationship instance of Party will ...
Yash Chowdhary's user avatar
0 votes
2 answers
302 views

Exclusion With Many to Many Relationships

I have created a select statement that show all the topics that are assigned to a book. Now I am trying to create a Select statement that shows all the topics that are not assigned to the book. Book ...
JAMES MICHAEL OLSON's user avatar
0 votes
0 answers
223 views

Help structuring a query with multiple many-to-many relationships

Assume that there are 4 tables, with association tables "between" each of them: Machines Products Option Groups Options Machines may serve many products, and a product may "belong to" many machines. ...
CSamuelLents's user avatar
0 votes
0 answers
27 views

More than one path between M-M tables

I'm trying to figure out if it is bad practice to have more than one path between tables that are related via many-to-many relationships. I have 3 user-facing tables: Dupe, Cue, and Take. There is a ...
slondike's user avatar
0 votes
0 answers
26 views

Variation on a join table

So a join table for many-to-many is typically(?) a two-column table with foreign keys to two other tables. I have a colleague that insists on putting an FK in two tables that are FKs to a "join" ...
Jeff Lowery's user avatar
0 votes
2 answers
61 views

How to link books of series together?

I have to link all the books in series together but I'm not sure. I have a SERIES_ID under which there is a name for a series, author, number of books and number book in the series. I'm not sure ...
Josh Antony's user avatar
0 votes
1 answer
78 views

Need help designing a query to pull a list of songs based on ranking and the last play date

I have a database of a list of songs used during a performance. The main table, tblSongs, has a Field that represents a Ranking, 1 being worst, 5 being best. The table is linked to tblEvents which ...
Matt Greer's user avatar
0 votes
1 answer
226 views

Model data with many to many and overrides

I'm having some trouble modeling the database for this particular scenario in Postgres: We have a set of toys that contain several pieces. Each piece is associated with one or more materials. All of ...
BrDaHa's user avatar
  • 101