Multiple relationships

jason_nevin

Registered User.
Local time
Today, 02:19
Joined
Nov 22, 2002
Messages
46
I have an address table which had five one-to-many RI relationships with other tables. I recently added two more tables/relationships and it seems to have slowed down my database. I made other changes at the same time so can't be sure. Would I be correct in saying that this is something that can cause performance problems? Is there anything I can do to improve the performance?
 
The problem with RI is that it requires extra work by Access (and extra design work by you) to maintain it properly. You are quite right that adding more tables with RI-class constraints on them will slow down performance. It is a cost of doing business on ANY database, I'm afraid, but there are ways to mitigate the problem.

Tricks that folks can play to reduce the amount of work include such things as always using the shortest keys possible. Use prime keys based on autonumber fields only for tables with potentially unlimited range, but perhaps you can use keys of only one or two bytes for lookup tables with a known, more limited data range.

Normalization is always desirable and without it, RI becomes problematic. But RI is not always desirable. Only you know what is in your tables, and this next is not intended as a criticism, just a suggestion. Consider whether each of those seven tables really requires RI or whether you might wish to relax that requirement for some of the tables. I also wonder if you have too many separated tables if all of them include RI to the same main table. Of course, if each table further joins to different tables besides that main table, then you should, indeed, separate them. But I wonder about possible proliferation of tables where consolidation might be preferable. Reducing the number of tables reduces the work done for RI checking. Just a suggestion for your consideration, not finger-pointing!

Another important issue is indexes. (Indices?) Since you could not even set up RI without a primary key on the main table, I know you MUST have that, and I know it has to be properly and uniquely indexed. But do you have similar non-unique indexes on the child tables in order to provide faster access to the field that is the foreign key in the child corresponding to the prime key in the parent? Indexes on such fields can help because they provide a faster data source for RI checking. (Has to do with how much data you can fit in a single Access block-buffer. Smaller index = more data in a single block input = faster scan for records affected by RI.)

If you don't already have such an index on the child tables, I would add an index to each table and make it hold ONLY the FK corresponding to the main table's PK. Even if no other program action requires use of such an index. Which I doubt anyway since you probably have JOIN queries linking the main table and your child tables, so such indexes would be useful there, too.

Supplement: On re-reading the problem, I see it is possible that the table with these relationships might be a child of seven different tables rather than a parent of seven tables. The suggestions of reducing key size and putting an index on the table in question is STILL a good idea even if the other idea (consolidation of multiple tables) might not work.
 
Last edited:
Relationships

The database is configured as follows;

One parent record (the enquiry);

Multiple child records (site addresses);

7 different types of child record (project types).

There are 1-many RI relationships in all above. The project types are vastly different and require different information to be captured (I'd say 25% of the info is common to all tables).

As well as these tables there is data such as customer addresses, staff information, dropdown items which have normal 1-1 relationships usually based on FK/PK. Often these tables have several relationships (customer addresses are accessed all over the place). This obviously make for a very complicated relationship map.

Does this sound like a normalised database to you?
 
As an addition;

All of my primary keys are autonumber and all of the foreign keys are long integers. Is there a more efficient way of storing the foreign key? The foreign keys are all indexed duplicates OK.
 
I have to disagree with Doc. RI is always desirable. Without it YOU need to programmatically prevent orphans. Never program something that has already been programmed for you. You cannot do this more efficiently than Jet and the risk of bad data is very high. The only place where I would not use RI is in a data warehouse database where the individual tables are never updated directly by users. All records are periodically copied from the transaction databases and reflect the production system at a point in time. Data warehouses are used only for reporting and analysis tasks.

1-1 relationships are extremely rare so if you have several of these the design is suspect. You will need to post a clear picture of your relationship diagram if you want specific design help. Make certain that the primary and foreign key fields are visible in all tables as well as as many columns as possible.
 

Users who are viewing this thread

Back
Top Bottom