472,354 Members | 1,542 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,354 software developers and data experts.

Junction table design options

As an example, I am building an authentication mechanisim that will use
data in the 3 left tables to determine rights to objects in a
destination table, diagrammed below. In this structure, multiple
records in the left tables will point to multiple records in the right
table. Normally, I would approach this problem using junction tables
(LeftID, RightID) to create many-to-many joins.

However, given the structure of each table is nearly identical (as far
as the linking IDs are concerned), I could also use a single junction
table with columns for each available table ID (LeftID1, LeftID2,
LeftID3, RightID). In this table, only two IDs would be utilized per
row (LeftIDx -> RightID).

In both designs, the needed rights information is returned from fairly
simple views, thus the end result is equivalent. The advantage to the
second, multi-ID junction table design, is a simpler database
structure. However, never using this approach before, I am unsure of
the potential future performance impacts.

Any significant downsides to this second design? Examples of an
abbreviated structure follow:

Data Tables
-----------
LeftTable1
LeftID1 (int)
Data1

LeftTable2
LeftID2 (int)
Data2

LeftTable3
LeftID3 (int)
Data3

DestinationTable
RightID (int)
Data
Linking tables option 1
-----------------------
JunctionTable1
LeftID1
RightID

JunctionTable2
LeftID3
RightID

JunctionTable3
LeftID3
RightID
Linking table option 2
----------------------
Junction
ID1 (int)
ID2 (int)
ID3 (int)
DestinationID (int)

Jul 20 '05 #1
1 3957
(mk***@yahoo.com) writes:
As an example, I am building an authentication mechanisim that will use
data in the 3 left tables to determine rights to objects in a
destination table, diagrammed below. In this structure, multiple
records in the left tables will point to multiple records in the right
table. Normally, I would approach this problem using junction tables
(LeftID, RightID) to create many-to-many joins.

However, given the structure of each table is nearly identical (as far
as the linking IDs are concerned), I could also use a single junction
table with columns for each available table ID (LeftID1, LeftID2,
LeftID3, RightID). In this table, only two IDs would be utilized per
row (LeftIDx -> RightID).


There is no general answer to this question. You should pick the one that
best describes the business problem. However, that said, it seems a lot
more probable that the three-table design is the right one.

To wit, one single table is right when there is a correllation in the
many-to-many relationship. If the RightID-entity always has a relation
with the three different LeftID-identity, and these there together
compose a set, then that design makes sense. But if the relations are
unrelated to each other, there is no sense to have a common table. And
the latter scenario seems much more likely.

What you have missed to consider is whether the columns are to be
nullable or not. In a junction table, the primary key is typically
the two keys from the joined tables. In a table that joins four different
tables, all four keys would compose the key of the four-join table.
And remember that primary keys can not have NULL values.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Marcy | last post by:
I am trying to build a database to keep track of training topics completed by people in my department. Our department has a set of 37 training topics. There are 7 job classifications in the...
1
by: Riley DeWiley | last post by:
I have an application with two tables, A and B. Each has an autonumber unique ID field, plus other data. I have a junction table, AB, containing fields AID, BID, and Count (a number). AB has...
1
by: LurfysMa | last post by:
I am working on an electronic flashcard program. Most of the subjects are simple lists of questions and answers. Those seem to be working. Some of the "subjects" have "categories" of questions. ...
4
by: yanjie.ma | last post by:
Hi, I've got a two part question on table and form design (sorry for the length but it takes a bit to explain). Our sales department uses a look-up table to help the them select the best...
3
by: inthemix | last post by:
My goal is to have a sub-form located on the main form which containts a listbox. The user will be able to select anany number of offices (by officeName) from this listbox. IMO the design is very...
1
by: que576 | last post by:
I have created a junction table so that I can relate data from 2 other tables. Table 1 - Category Table (has the following fields with data) CatID (primary key) CategoryName CategoryStatus ...
2
by: Henry Stockbridge | last post by:
Hi, I need a recommendation when to add a record to a junction table that complements a many to many relationship. There will be a Contacts form, and an Interests subform with the parent/child...
1
by: bg_ie | last post by:
I'm designing a database with 3 tables called Function, Test and Scene. A Function has multiple Tests, but a Test has only one Function. A many to many relationship exists between Test and Scene...
3
by: dbertanjoli | last post by:
Hello, I have a questinarrie webform I use INSERT statement(s) to insert a new record in the User and Questions tables and then (HERE IS MY PROBLEM) I need to update my junction table...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.