473,408 Members | 1,822 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,408 software developers and data experts.

Multi-Duplicates OK-Primary Keys

Hey all,

(Access 2000)
I've been having a horror story with this design problem. My Database is
Structured like This: AUTHORS, BOOKS, PAGES. Those are the Tables and each
Item in each table needs a unique ID# based on its context.

Primary Keys
AUTHORS = AuthorID - NO Duplicates

BOOKS = AuthorID - Dups OK
BookID - Dups OK

PAGES = AuthorID - Dups OK
BookID - Dups OK
PageNumber - Dups OK

So for instance the pages need to number from 1 to <i>n</i> for each Book of
each Author.

The problem I had after I set this up is that from PAGES to BOOKS
I could NOT use referencial integrity because it could not identify a unique
Primary Key, (because I used Duplicates OK = True in BOOKS)

-> Is this not a valid way link a 3 level database?

I tried using auto-number primary keys but that killed the validation for
duplicates in the table.

-> Shouldn't Access treat two(or more) Primary Keys with Dups OK = True the
same as one primary Key with Dups = NO so that I can set up integrity
between tables using these two primary keys?

Thanks for any insight!
~Philip
Nov 12 '05 #1
7 5326
Philip wrote:
-> Is this not a valid way link a 3 level database?
Oh yes it is.
I tried using auto-number primary keys but that killed the validation for
duplicates in the table.
A *very good* observation. Write it down for future reference. :-)
-> Shouldn't Access treat two(or more) Primary Keys with Dups OK = True the
same as one primary Key with Dups = NO so that I can set up integrity
between tables using these two primary keys?


Nah. You have *one* primary key, which may consist of more fields, each
with its own index (duplicate or not) but the composite *MUST BE UNIQUE*
otherwise it doesn't work as primary key.

In the design view of the tables, select all rows pertaining to the key,
and only then press the 'key' button to set those as primary key.

--
Bas Cost Budde
http://www.heuveltop.org/BasCB
but the domain is nl

Nov 12 '05 #2
"Philip" <Ph****@afterapriltax.com> wrote in message
news:Wq*******************@nwrddc01.gnilink.net...
Hey all,

(Access 2000)
I've been having a horror story with this design problem. My Database is
Structured like This: AUTHORS, BOOKS, PAGES. Those are the Tables and each
Item in each table needs a unique ID# based on its context.

Primary Keys
AUTHORS = AuthorID - NO Duplicates

BOOKS = AuthorID - Dups OK
BookID - Dups OK

PAGES = AuthorID - Dups OK
BookID - Dups OK
PageNumber - Dups OK

So for instance the pages need to number from 1 to <i>n</i> for each Book of each Author.

The problem I had after I set this up is that from PAGES to BOOKS
I could NOT use referencial integrity because it could not identify a unique Primary Key, (because I used Duplicates OK = True in BOOKS)

-> Is this not a valid way link a 3 level database?

I tried using auto-number primary keys but that killed the validation for
duplicates in the table.

-> Shouldn't Access treat two(or more) Primary Keys with Dups OK = True the same as one primary Key with Dups = NO so that I can set up integrity
between tables using these two primary keys?

Thanks for any insight!
~Philip

Do you realise the difference between a primary key and a unique index? You
can have a primary key PageID which is simply an autonumber to identify the
record, yet still enforce a unique index so that you cannot have a duplicate
AuthorID, BookID, PageNumber.
While looking in the table in design view, select View>Indexes and create a
new one called idxPages then select these 3 fields, one below the other, and
set primary to 'no' but unique to 'yes'.

Will this help you do what you want?

Fletcher
Nov 12 '05 #3
Thank you for the swift response!
I was able to get the relationship working for AUTHOR-BOOK-PAGE with just a
few tweaks
Nov 12 '05 #4
> Do you realise the difference between a primary key and a unique index?
You
can have a primary key PageID which is simply an autonumber to identify the record, yet still enforce a unique index so that you cannot have a duplicate AuthorID, BookID, PageNumber.
While looking in the table in design view, select View>Indexes and create a new one called idxPages then select these 3 fields, one below the other, and set primary to 'no' but unique to 'yes'.

Will this help you do what you want?


Thank you for the explanation, another small piece of my ignorance has died
at your hands, however,
I ran into an issue with the second part of the DB and your explation seemed
like it would provide the solution, but I cannot get it to work the way you
described...

The following relationship describes the same AUTHOR DB with two different
Tables

Primary Keys
AUTHORS = AuthorID - DupNO

BOOKCATEGORYS = AuthorID - DupOK
BookCatId - DupOK
BookCatOrder - DupOK

BOOKORDER = AuthorID - DupOK
BookCatId - DupOK
BookOrder - DupOK

Each Author has different categorys for his/her books, each category has a
certain list of books and an order for them. Note: The Categories also have
an BookCatOrder ID

I tried your suggestion and Made The first two Fields (AuthorID and
BookCatID) the only primary's
while I made a multi field index for the two Tables with all three fields,
so those fields would be unique.

This allowed me to create a relationship with integrity but did NOT validate
uniqueness!

I was still able to enter data like this for BOOKCATEGORYS
AuthorId | CatId | BookCatOrder
1 | 1 | 2
1 | 2 | 2

Two different Categories are claiming to be the second in the Category Order
It was only validating the primary keys for uniqueness

-> Are there limitations when using index's with the primary keys on same
fields? I have never used multi-field indexes.

Thanks,
~Philip
Nov 12 '05 #5
"Philip" <Ph****@afterapriltax.com> wrote in message
news:IY*******************@nwrddc02.gnilink.net...
Do you realise the difference between a primary key and a unique index? You
can have a primary key PageID which is simply an autonumber to identify

the
record, yet still enforce a unique index so that you cannot have a

duplicate
AuthorID, BookID, PageNumber.
While looking in the table in design view, select View>Indexes and

create a
new one called idxPages then select these 3 fields, one below the other, and
set primary to 'no' but unique to 'yes'.

Will this help you do what you want?


Thank you for the explanation, another small piece of my ignorance has

died at your hands, however,
I ran into an issue with the second part of the DB and your explation seemed like it would provide the solution, but I cannot get it to work the way you described...

The following relationship describes the same AUTHOR DB with two different
Tables

Primary Keys
AUTHORS = AuthorID - DupNO

BOOKCATEGORYS = AuthorID - DupOK
BookCatId - DupOK
BookCatOrder - DupOK

BOOKORDER = AuthorID - DupOK
BookCatId - DupOK
BookOrder - DupOK

Each Author has different categorys for his/her books, each category has a certain list of books and an order for them. Note: The Categories also have an BookCatOrder ID

I tried your suggestion and Made The first two Fields (AuthorID and
BookCatID) the only primary's
while I made a multi field index for the two Tables with all three fields,
so those fields would be unique.

This allowed me to create a relationship with integrity but did NOT validate uniqueness!

I was still able to enter data like this for BOOKCATEGORYS
AuthorId | CatId | BookCatOrder
1 | 1 | 2
1 | 2 | 2

Two different Categories are claiming to be the second in the Category Order It was only validating the primary keys for uniqueness

-> Are there limitations when using index's with the primary keys on same
fields? I have never used multi-field indexes.

Thanks,
~Philip

Hi Philip
I did take a second read through and still didn't get it - sorry. I think
the problem is I can't quite understand the table structure (I'm not even
100% sure whether the word 'order' means 'position in a list' or 'order as
in a sales / purchase order'). Perhaps it's too late at night or perhaps
someone else can help out here, but while an AUTHORS table seems straight
forward, I can't see the sense of the structure for BOOKCATEGORYS.

Anyway, my general point was that you could have a single autonumber for
each table as the primary key. This allows you to refer to this record in
another table. If you want to keep a value, or combination of values
unique, then you can use additional indexes. For example,
AuthorId | CatId | BookCatOrder
1 | 1 | 2
1 | 2 | 2


Was your objection that BookCatOrder=2 should occur no more than once in the
table? If you need this to be the case, then have a single index that says
that BookCatOrder must be unique. Your table can contain a number of
indexes - each involving single of multiple fields and each with the ability
to be unique. Obviously only one can be the primary key, but this does not
(and perhaps should not) contain any meaningful data (ie arbitrarily
assigned autonumber).
Fletcher




Nov 12 '05 #6
Fletcher,

I apologize because it DID work exactly as you explained! I think I've been
working on this project far too long, that annexed to my lack of knowledge,
accounts for my misconceptions.

My problem below (where order = order in list btw) was because I index'd all
*three* fields
The two example records are correctly unique! I needed to index AuthorId and
BookCatOrder only.
I was still able to enter data like this for BOOKCATEGORYS
AuthorId | CatId | BookCatOrder
1 | 1 | 2
1 | 2 | 2


Thank you!
~Philip
Nov 12 '05 #7
"Philip" <Ph****@afterapriltax.com> wrote in message
news:O%***************@nwrddc03.gnilink.net...
Fletcher,

I apologize because it DID work exactly as you explained! I think I've been working on this project far too long, that annexed to my lack of knowledge, accounts for my misconceptions.

My problem below (where order = order in list btw) was because I index'd all *three* fields
The two example records are correctly unique! I needed to index AuthorId and BookCatOrder only.
I was still able to enter data like this for BOOKCATEGORYS
AuthorId | CatId | BookCatOrder
1 | 1 | 2
1 | 2 | 2


Thank you!
~Philip

Glad you got it to work. Thanks for the feedback.
Fletcher

Nov 12 '05 #8

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

Similar topics

37
by: ajikoe | last post by:
Hello, Is anyone has experiance in running python code to run multi thread parallel in multi processor. Is it possible ? Can python manage which cpu shoud do every thread? Sincerely Yours,...
4
by: Frank Jona | last post by:
Intellisense with C# and a multi-file assembly is not working. With VB.NET it is working. Is there a fix availible? We're using VisualStudio 2003 Regards Frank
12
by: * ProteanThread * | last post by:
but depends upon the clique: ...
0
by: frankenberry | last post by:
I have multi-page tiff files. I need to extract individual frames from the multi-page tiffs and save them as single-page tiffs. 95% of the time I receive multi-page tiffs containing 1 or more black...
6
by: cody | last post by:
What are multi file assemblies good for? What are the advantages of using multiple assemblies (A.DLL+B.DLL) vs. a single multi file assembly (A.DLL+A.NETMODULE)?
6
by: Joe | last post by:
I have 2 multi-list boxes, 1 displays course categories based on a table called CATEGORIES. This table has 2 fields CATEGORY_ID, CATEGORY_NAME The other multi-list box displays courses based on...
4
by: mimmo | last post by:
Hi! I should convert the accented letters of a string in the correspondent letters not accented. But when I compile with -Wall it give me: warning: multi-character character constant Do the...
5
by: bobwansink | last post by:
Hi, I'm relatively new to programming and I would like to create a C++ multi user program. It's for a project for school. This means I will have to write a paper about the theory too. Does anyone...
0
by: Sabri.Pllana | last post by:
We apologize if you receive multiple copies of this call for papers. *********************************************************************** 2008 International Workshop on Multi-Core Computing...
1
by: mknoll217 | last post by:
I am recieving this error from my code: The multi-part identifier "PAR.UniqueID" could not be bound. The multi-part identifier "Salary.UniqueID" could not be bound. The multi-part identifier...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.