Questions tagged [associative-table]
19 questions
9
votes
3 answers
"Master" associative table?
Consider a model for matching clients and sevices. Clients may be both providers of and consumers of services at various times. Clients may be individuals or groups (companies), the latter having multiple contacts. Contacts may have multiple…

djhill8262
- 235
- 3
- 5
3
votes
3 answers
MySQL many to many relationship matching
I'm making a cocktail database, and right now I have three tables:
drinks has columns drinks_id and drinks_name
ingredients has columns ingredients_id and ingredients_name
The third is a simple relationship table called recipes that has drinks_id…

caltangelo
- 264
- 1
- 11
3
votes
1 answer
SQL insert to fill an associative table with conditions
I have two tables and an associative table between them (let's call them Tab1, Tab2 and ATab).
Tab1 and Tab2 have those very same fields (for example purpose) :
Id.
Name.
In my ATab, I want to insert record to associates Tab1 and Tab2 with their…

Andy M
- 5,945
- 7
- 51
- 96
2
votes
5 answers
Using MYSQL Associative Table and JOIN
Here is the structure of the three tables:
CREATE TABLE `contacts` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(99) DEFAULT NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
CREATE TABLE…

tlaffoon
- 65
- 2
- 10
2
votes
1 answer
How to persisting attributes in an Associative Table using JPA and Hibernate?
I want to save attributes on an associative table in hibernate and don't know how.
I came up with the following example: I have a table USERS, a table MEDIA (where movies and books are stored) and an associative table called USER_MEDIA where I store…
user689842
1
vote
1 answer
nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property
Based on this tutorial I'm trying to create Many-to-Many Relationship Using a Composite Key
Eventually I get the following error
The composite key itself have the following structure:
@Embeddable
@Data
public class MovieRatingsKey implements…

ErichFelzinger
- 17
- 4
1
vote
1 answer
Getting and inserting AUTO INCREMENTED rows into an associative-table?
I have two inputs:
Basket Name:
AND
Fruits
1
vote
1 answer
When to use multiple foreign keys in a single table vs using associative tables?
I'm trying to understand when to include multiple foreign keys into a table vs when to use associative tables.
Edit: Added a diagram to hopefully make it easier to understand.
I have a settings system that many settings are specific to a division or…

user29021
- 65
- 1
- 5
1
vote
1 answer
SQLAlchemy testing data to associative object
I'm building an DB using sqlalchemy, and I would like to test my model. Even if I read few topics and going through the documentation, I'm not sure I understood how to load data into the associative tables.
I created the two classes this way :
class…

thiebaut fischer
- 73
- 2
- 8
1
vote
1 answer
jOOQ and bridge tables
I'm trying to imagine how to use jOOQ with bridge tables.
Suppose you have
CREATE TABLE TableA (
id BIGSERIAL PRIMARY KEY
)
CREATE TABLE TableB (
id BIGSERIAL PRIMARY KEY
)
CREATE TABLE TableBridge (
id BIGSERIAL,
table_a_id INTEGER NOT…

mat_boy
- 12,998
- 22
- 72
- 116
1
vote
0 answers
Working with additional attribute of has_many :through associative model
I've got the following model relations:
class Song < ActiveRecord::Base
has_many :song_in_playlists, :dependent => :destroy
has_many :playlists, :through => :song_in_playlists
attr_accessible :song_in_playlists_attributes
…

kah
- 170
- 1
- 12
1
vote
2 answers
Advice on MySQL and many-to-many in populating the Associative Entity
I'm designing a database that contains a list of recipes and their ingredients and now i'm in the processing of linking the individual ingredients to their respective recipes. However, i'm having trouble deciding on the best course of action on how…

BertyLurch
- 159
- 1
- 8
0
votes
1 answer
associative table vs data table
I've three entities (entity_1, entity_2 and entity_3) and each of them can have multiple videos but one video relates to only one entity (one-to-many). Now I want to know which is the best practice to create a db schema for this.
The solution with…

Saxony
- 1
- 1
0
votes
1 answer
Insert multiple rows with associative entity
I'm facing a problem for a project I'm working on.
I have a MySQL database that I use with a Node.js script (thanks to the mysql npm package).
I have two entities, A and B, with a many-to-many relationship. Between them, there's a associative entity…

Rascafr
- 174
- 11
0
votes
1 answer
Delete based on primary key from associative table - Error
I'm trying to delete 1 record based on primary key from (3) tables.
Here is the statement that I'm using
DELETE FROM CUSTOMER
WHERE EXISTS
( SELECT MERCHANTNAME
FROM CREDITCARD
WHERE MERCHANTNAME = 'VISA');
Deleting record of a customer…

Riddick
- 493
- 1
- 4
- 7