473,396 Members | 2,016 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.

how do you programmatically create a relationship WITHOUT creating an index?

Hi gang,

Please help. I've been through the Access help, searched the Web, and
I can't seem to get a straight answer. As the Subject line suggests, I
want to run a fairly simple VB/Access Sub Function/Module that creates
relationships for my tables. The problem is that I need to provide for
some tables that may have > 32 relationships (which is apparently the
limit on Indexes that Access can support). How can I prevent Access
from automatically creating these indexes, AND still get referential
integrity, as viewable in my Relationships window. I started with
this, which works fine until the 32 index-limit is reached:

strSQL = "ALTER TABLE Movement_Authority ADD CONSTRAINT [FKp_115]
FOREIGN KEY ([FKp_Limit]) REFERENCES Limit;
DoCmd.RunSQL strSQL

Then I read that this would work:

strSQL = "ALTER TABLE Movement_Authority ADD CONSTRAINT NO INDEX
[FKp_115] FOREIGN KEY ([FKp_Limit]) REFERENCES Limit;
DoCmd.RunSQL strSQL

I tried the "NO INDEX" key phrase everywhere imaginable, as well as
with "As Database" using .Execute, still to no avail. Using DROP
obliterates the referential integrity altogether. I sincerely hope
SOMEONE knows what I can do, and hopefully it won't require a page of
code and importing or using all sorts of esoteric do-dads...what the
heck, I'll take any solution. HELP!!! Feel free to post and/or email
me directly. Thanks in advance, -Brian sa***@leapse.com
Nov 13 '05 #1
8 4293
Hi Brian.

If we are talking about JET here (i.e. if your tables are in an Access
database), you will not be able to do that. JET must have a unique index in
order to create a relationship with RI.

Your table may have some spurious indexes that you can dump. By default,
Access creates an index on any field that has a name ending in ID, Code,
Num, etc. (To avoid that: Tools | Options | Tables/Queries | Autoindex.)
These indexes are listed in the Indexes dialog (Tools menu) in table design,
and you can delete them there. Additionally Access creates hidden indexes on
all the foreign key fields that are involved in relationships with RI, so if
you manually index your foreign keys as well, you can remove these
duplicates as well.

--
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.

"Brian S. Smith" <sa***@leapse.com> wrote in message
news:4a**************************@posting.google.c om...

Please help. I've been through the Access help, searched the Web, and
I can't seem to get a straight answer. As the Subject line suggests, I
want to run a fairly simple VB/Access Sub Function/Module that creates
relationships for my tables. The problem is that I need to provide for
some tables that may have > 32 relationships (which is apparently the
limit on Indexes that Access can support). How can I prevent Access
from automatically creating these indexes, AND still get referential
integrity, as viewable in my Relationships window. I started with
this, which works fine until the 32 index-limit is reached:

strSQL = "ALTER TABLE Movement_Authority ADD CONSTRAINT [FKp_115]
FOREIGN KEY ([FKp_Limit]) REFERENCES Limit;
DoCmd.RunSQL strSQL

Then I read that this would work:

strSQL = "ALTER TABLE Movement_Authority ADD CONSTRAINT NO INDEX
[FKp_115] FOREIGN KEY ([FKp_Limit]) REFERENCES Limit;
DoCmd.RunSQL strSQL

I tried the "NO INDEX" key phrase everywhere imaginable, as well as
with "As Database" using .Execute, still to no avail. Using DROP
obliterates the referential integrity altogether. I sincerely hope
SOMEONE knows what I can do, and hopefully it won't require a page of
code and importing or using all sorts of esoteric do-dads...what the
heck, I'll take any solution. HELP!!! Feel free to post and/or email
me directly. Thanks in advance, -Brian sa***@leapse.com

Nov 13 '05 #2
Perhaps you could tell us a little more about your database design.
The need for over 32 relationships for a single table suggests that perhaps
a different table structure could be appropriate.

HTH
- Turtle

"Brian S. Smith" <sa***@leapse.com> wrote in message
news:4a**************************@posting.google.c om...
Hi gang,

Please help. I've been through the Access help, searched the Web, and
I can't seem to get a straight answer. As the Subject line suggests, I
want to run a fairly simple VB/Access Sub Function/Module that creates
relationships for my tables. The problem is that I need to provide for
some tables that may have > 32 relationships (which is apparently the
limit on Indexes that Access can support). How can I prevent Access
from automatically creating these indexes, AND still get referential
integrity, as viewable in my Relationships window. I started with
this, which works fine until the 32 index-limit is reached:

strSQL = "ALTER TABLE Movement_Authority ADD CONSTRAINT [FKp_115]
FOREIGN KEY ([FKp_Limit]) REFERENCES Limit;
DoCmd.RunSQL strSQL

Then I read that this would work:

strSQL = "ALTER TABLE Movement_Authority ADD CONSTRAINT NO INDEX
[FKp_115] FOREIGN KEY ([FKp_Limit]) REFERENCES Limit;
DoCmd.RunSQL strSQL

I tried the "NO INDEX" key phrase everywhere imaginable, as well as
with "As Database" using .Execute, still to no avail. Using DROP
obliterates the referential integrity altogether. I sincerely hope
SOMEONE knows what I can do, and hopefully it won't require a page of
code and importing or using all sorts of esoteric do-dads...what the
heck, I'll take any solution. HELP!!! Feel free to post and/or email
me directly. Thanks in advance, -Brian sa***@leapse.com

Nov 13 '05 #3
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:40***********************@freenews.iinet.net. au...
Hi Brian.

If we are talking about JET here (i.e. if your tables are in an Access
database), you will not be able to do that. JET must have a unique index in order to create a relationship with RI.

Your table may have some spurious indexes that you can dump. By default,
Access creates an index on any field that has a name ending in ID, Code,
Num, etc. (To avoid that: Tools | Options | Tables/Queries | Autoindex.)

I don't think this behaviour applies when you create constraints using DDL.
Nov 13 '05 #4
"Brian S. Smith" <sa***@leapse.com> wrote in message
news:4a**************************@posting.google.c om...
Hi gang,

Please help. I've been through the Access help, searched the Web, and
I can't seem to get a straight answer. As the Subject line suggests, I
want to run a fairly simple VB/Access Sub Function/Module that creates
relationships for my tables. The problem is that I need to provide for
some tables that may have > 32 relationships (which is apparently the
limit on Indexes that Access can support). How can I prevent Access
from automatically creating these indexes, AND still get referential
integrity, as viewable in my Relationships window. I started with
this, which works fine until the 32 index-limit is reached:


I think that Access does not create an index when you define a constraint
using DDL. Perhaps constraints themselves count towards the 32 index limit.

BTW, a table with 32 foreign keys often indicates a design problem, but you
may have a special case.
Nov 13 '05 #5
"John Winterbottom" <as******@hotmail.com> wrote:
BTW, a table with 32 foreign keys often indicates a design problem, but you
may have a special case.


And I have one of those special cases. An MDB with 150 tables with at least 30 or
40 joins to the Job table. So it's unlikely but possible.

We also print the relationships diagram on a 36" plotter. It's about as tall as it's
wide. I can fit one more layer of tables, maybe two at the bottom before I run out
of room.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Nov 13 '05 #6
"Tony Toews" <tt****@telusplanet.net> wrote in message
news:3t********************************@4ax.com...
"John Winterbottom" <as******@hotmail.com> wrote:
BTW, a table with 32 foreign keys often indicates a design problem, but youmay have a special case.
And I have one of those special cases. An MDB with 150 tables with at

least 30 or 40 joins to the Job table. So it's unlikely but possible.

We also print the relationships diagram on a 36" plotter. It's about as tall as it's wide. I can fit one more layer of tables, maybe two at the bottom before I run out of room.

Oh, yes I know these cases do exist - that's why I add the proviso :) A
little more on this subject though - after some testing it seems that when
you create a FK constraint using a DDL script, an index is added to the
tables' DAO indexes collection, even though no index is visible through the
UI. Perhaps Jet creates in index to enforce the constraint. AFAIK this is
different behaviour to sql server, where a constraint and an index are two
separate things.
Nov 13 '05 #7
"John Winterbottom" <as******@hotmail.com> wrote:
Oh, yes I know these cases do exist - that's why I add the proviso :) A
little more on this subject though - after some testing it seems that when
you create a FK constraint using a DDL script, an index is added to the
tables' DAO indexes collection, even though no index is visible through the
UI. Perhaps Jet creates in index to enforce the constraint. AFAIK this is
different behaviour to sql server, where a constraint and an index are two
separate things.


Yup, Jet does the same thing if you create a relationship via the GUI and the DAO
relationships collection.

Tony

--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Nov 13 '05 #8
Thank you all for your prompt responses! This is a great group.

Sounds like I'm SOL. Just to clear things up, though, the table and
its relationships are what is given to me in another form in another
application, so I know it is not an optimal design--and it really
isn't intended to be; it's more of a conceptual model.

But John, you have given me a glimmer of hope with your comment about
DDL. As you know, Access automatically creates indexes when you
specify a foregin key constraint. Could you give me some guidance on
how I can avoid this via DDL? Here's the example of what I'm using
agian:

strSQL = "ALTER TABLE Movement_Authority ADD CONSTRAINT [FKp_115]
FOREIGN KEY ([FKp_Limit]) REFERENCES Limit;
DoCmd.RunSQL strSQL

What is the syntax I can use to create a relationship WITHOUT an
index???

Thanks a whole bunch.

-Brian
"John Winterbottom" <as******@hotmail.com> wrote in message news:<2i************@uni-berlin.de>...
"Brian S. Smith" <sa***@leapse.com> wrote in message
news:4a**************************@posting.google.c om...
Hi gang,

Please help. I've been through the Access help, searched the Web, and
I can't seem to get a straight answer. As the Subject line suggests, I
want to run a fairly simple VB/Access Sub Function/Module that creates
relationships for my tables. The problem is that I need to provide for
some tables that may have > 32 relationships (which is apparently the
limit on Indexes that Access can support). How can I prevent Access
from automatically creating these indexes, AND still get referential
integrity, as viewable in my Relationships window. I started with
this, which works fine until the 32 index-limit is reached:


I think that Access does not create an index when you define a constraint
using DDL. Perhaps constraints themselves count towards the 32 index limit.

BTW, a table with 32 foreign keys often indicates a design problem, but you
may have a special case.

Nov 13 '05 #9

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

Similar topics

4
by: Thomas Jespersen | last post by:
Hello I want to create a MSI file programmatically. Do you know of any third party .NET component which can help me with that? I'm going to use it like a self extracting zip. So it is not...
6
by: ALthePal | last post by:
Hi, I'm not sure if we are able to or even how to loop through the web forms in a VB.NET project during design time. In MSAccess we are able to go through the database -> forms collection and...
4
by: Melissa | last post by:
I have a frontend file named CustomerApp and backend file named CustomerData. CustomerApp is at C:\Customer Database and CustomerData is at S:\Customer Database. Could someone help me with the code...
3
by: teedilo | last post by:
Our MS SQL (SQL Server 2000) DBA has database privileges locked down pretty tightly. We end users/developers do not have administrator privileges for most databases. That arrangement has worked...
5
by: Brian McClellan | last post by:
Just wondering if anyone has a simple example of creating a gridview completely programmatically, i'm not doing anything terribly sophisticated. When creating the gridview declaratively evertying...
14
by: mistral | last post by:
Need php script to create mySQL database programmatically; since hosting configuration may not allow create database from script, script also need eliminate/rewrite all restrictions in appropriate...
2
by: Wayne Deleer | last post by:
Hi All, I'm currently working on a project, and I've come to a part where I want to add data to a GridView. BUT, I want to do it programmatically, with alot of control over everything. In my...
0
by: Shootah | last post by:
Hi, I have succeeded in adding automated relationships with refference tables after importing an excel file created from a query to an Access database. However I have the following problem: ...
11
by: =?Utf-8?B?UGV0ZXIgSw==?= | last post by:
I am working with Visual Studio or alternately with Expression Web. I need to create about 50 aspx pages with about 1200 thumbnali images, typically arranged in three to four groups per page,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.