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

proper model implementation for many-to-many tables with junction tables

I'm not using code first, I created a table called artists with an ID and name field, a table called albums with an id and title field and a junction_artists_albums table with artist_id and album_id. Here are my model/context classes: Artist: …
ab1428x
  • 794
  • 2
  • 8
  • 20
0
votes
2 answers

How to construct a Junction Table for Many-to-Many relationship without breaking Normal Form

I have these two tables, Company and Owner. Right now they are both in Normal Form, but I need to create a Many-to-Many relationship between them, since one Company can have many Owners and one Owner can have many Companies. I have previously gotten…
Bam
  • 478
  • 6
  • 19
0
votes
1 answer

MySQL junction table not updating after creating keys

I first created 2 tables. Later I realized I needed to add a M:M relationship between the two, so I created a junction table and created the necessary relationships between the tables. The problem I'm running into is that after creating the…
hyphen
  • 957
  • 1
  • 11
  • 31
0
votes
2 answers

Creating records for a junction table with calculated fields and testing the process

I am having trouble writing a test for a piece of code I am working on. I have two tables for which I am trying to create a junction table, as below: CREATE TABLE charges ( id bigint PRIMARY KEY, amount float, some_data hstore ) CREATE…
grobolom
  • 101
  • 1
  • 15
0
votes
1 answer

MySQL SELECT query on junction table with multiple tables

I have four tables, assuming they have only an id as a column each. listings feature location l_f_location as a junction table with FKs on listingId, featureId, locationId I try to query the l_f_location table for a given set of locationIds…
PMiller
  • 241
  • 1
  • 5
  • 15
0
votes
1 answer

Database schema for Assignment Website - Is this a Many-to-Many Relationship?

I am creating an asp.net website (through Expression Web 4 and Visual Web Developer 2010 Express), using a database created via Sql Server 2008. I am however stuck with regards to the database schema, which feeds into the website. The website being…
0
votes
1 answer

Junction table without primary key

Say I have a junction table to resolve a many to many relationship I have between two tables. My junction table also has its own 'Method' column to describe the relationship. Normally, I would make a composite primary key of [a], [b] and [method]…
Cody
  • 2,451
  • 2
  • 20
  • 19
0
votes
1 answer

Query a Junction Table from MS Access Database in a ASP / C# Webpage

I'm writing a ASP page where: Student Logs in -> Student Reaches Welcome Page w/ Link to Show them Their Enrolled Courses -> Linked Page Shows Course Info, Description etc. I have MS Access database that has 3 tables: Students (containing student…
adL
  • 79
  • 2
  • 2
  • 9
0
votes
2 answers

SELECT data with primary keys from another table?

I have a 'users' table, an 'offers' table, and a junction '*users_offers*' with userIDs and offerIDs. How to select every offer from offers that belongs to a particular user? I could achieve a solution (below) that actually starts select data from…
Geri Borbás
  • 15,810
  • 18
  • 109
  • 172
0
votes
1 answer

Junction Table in SQL Server

I am having difficulty creating a junction table in a new database. I used these queries to create the tables: CREATE TABLE dbo.EmployeeUnavailability ( ID INT IDENTITY(1,1) PRIMARY KEY, EmployeeName varchar(50), Monday varchar(10), Tuesday…
0
votes
1 answer

EF Code First Many to Many Relation Without an Entity

I have read many about how to configure many to many realtionships with EF Code First and fluent configuration. But I couldn't understand why I should create an extra entity for the junction table. Lets assume that I have the following…
Kadir.K
  • 366
  • 4
  • 17
0
votes
4 answers

Selective update in SQL Server

I've created a junction table like this one: http://imageshack.us/scaled/landing/822/kantotype.png I was trying to figure out a query that could able to select some rows - based on the PokémonID - and then updating only the first or second row after…
Mudkip
  • 373
  • 6
  • 27
0
votes
1 answer

NHibernate. Conform. Set composite primary key in junctiontable

I have two tables and I wand to create a junction table. I have this mapping. public UsertMap() { Table("Users"); Id(x => x.Id, map => map.Generator(Generators.Assigned)); Property(x => x.FirstName, map =>…
0
votes
1 answer

Rails 3: Possible to order with a junction-table?

I have a nested form which creates many locations for each post. Each location can also be used in multiple posts. E.g. Post 1 may have Location1, Location2 and Location3 AND Post 2 may have Location1, Location4 and Location5 I want these…
0
votes
1 answer

Design pattern - database many to many

I have a question about many-tomany relationship. I know that we have to create a junction table. But let say we have this scenario: one table for Customers one table for Orders one table for products One order can have many products and one product…
Camus
  • 827
  • 2
  • 20
  • 36
1 2 3
14
15