473,396 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Indexing on Junction Tables

Hi all,

I was wondering what's happening in a typical junction table where the
primary key is the combination of two foreign keys from other tables.
I suppose Access automatically creates a concatenated index on the two
attributes that comprise the primary key.
Should I be indexing each attribute separately as well?

Cheers!

Konstantinos
Nov 13 '05 #1
3 2464
If you create a relation between two tables and enforce referential
integrity, Access creates a hidden index on the foreign key field. There is
therefore no need to index your foreign key field yourself.

That remains true for a multi-field key such as the OrderDetails in
Northwind, where there are two relations going to 2 different tables (Orders
and Products), because that involves an index on each one.

However if you have a multi-field relation (a relationship to another table
based on 2 or more fields), Access will give you a multi-field index.
Rushmore can then use the first field in the index as if it were indexed
itself, but you may want to index the 2nd and subsequent fields yourself.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Kostas" <no*****@noemail.net> wrote in message
news:10*************@corp.supernews.com...
Hi all,

I was wondering what's happening in a typical junction table where the
primary key is the combination of two foreign keys from other tables.
I suppose Access automatically creates a concatenated index on the two
attributes that comprise the primary key.
Should I be indexing each attribute separately as well?

Nov 13 '05 #2
Thanks,
It's funny I was just at your website a minute ago which I frequently
consult. Thank you by the way for the advice and the tips you share in your
site.
Is there a way to see and manipulate those hidden indexes that access
creates?

Konstantinos

"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:41***********************@per-qv1-newsreader-01.iinet.net.au...
If you create a relation between two tables and enforce referential
integrity, Access creates a hidden index on the foreign key field. There
is therefore no need to index your foreign key field yourself.

That remains true for a multi-field key such as the OrderDetails in
Northwind, where there are two relations going to 2 different tables
(Orders and Products), because that involves an index on each one.

However if you have a multi-field relation (a relationship to another
table based on 2 or more fields), Access will give you a multi-field
index. Rushmore can then use the first field in the index as if it were
indexed itself, but you may want to index the 2nd and subsequent fields
yourself.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Kostas" <no*****@noemail.net> wrote in message
news:10*************@corp.supernews.com...
Hi all,

I was wondering what's happening in a typical junction table where the
primary key is the combination of two foreign keys from other tables.
I suppose Access automatically creates a concatenated index on the two
attributes that comprise the primary key.
Should I be indexing each attribute separately as well?


Nov 13 '05 #3
Loop through the Relations collection. This kind of thing:

Function ShowRel()
Dim db As DAO.Database
Dim rel As DAO.Relation
Dim fld As DAO.Field

Set db = CurrentDb()
For Each rel In db.Relations
Debug.Print rel.Name, rel.Table, rel.ForeignTable
For Each fld In rel.Fields
Debug.Print , fld.Name, fld.ForeignName
Next
Next

Set fld = Nothing
Set rel = Nothing
Set db = Nothing
End Function

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Kostas" <no*****@noemail.net> wrote in message
news:10*************@corp.supernews.com...
Thanks,
It's funny I was just at your website a minute ago which I frequently
consult. Thank you by the way for the advice and the tips you share in
your site.
Is there a way to see and manipulate those hidden indexes that access
creates?

Konstantinos

Nov 13 '05 #4

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

Similar topics

1
by: mksql | last post by:
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,...
3
by: Good Man | last post by:
Hi there I've designed some web applications that are fairly small scale (thousands of users) but my MySQL tables are indexed well and they all run quickly and efficiently. Today I decided to...
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...
5
by: ken | last post by:
Hi, Do Junction Tables need ID fields with Primary keys? For example if you store employee ID, employee name, Company ID, Company name. As you can see no field here can be a primary key since all...
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...
7
by: Ryan | last post by:
I have a bit of a problem with regards an indexing strategy. Well, basically there is no indexing strategy on a set of data I have at work. Now, I didn't create the design as I would have allowed...
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 ...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.