By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,466 Members | 1,756 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,466 IT Pros & Developers. It's quick & easy.

Unique index and null values

P: n/a
Any suggestions on how to get this to work:

My table includes a index that requires three combined fields to be
unique. However, sometimes the third field will be null....thereby
excluding the record from the uniqueness requirement.

Details:
tbl_Product_Licensor
Product_ID
Licensor_ID
Sublicensor_ID

A product will always have only one licensor, which may or may not
also have a sublicensor. How do I make this three field combo a unique
requirement when one can be null?

TIA...
Nov 12 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Why not make it zero??
"John" <so*********@hotmail.com> wrote in message
news:90**************************@posting.google.c om...
Any suggestions on how to get this to work:

My table includes a index that requires three combined fields to be
unique. However, sometimes the third field will be null....thereby
excluding the record from the uniqueness requirement.

Details:
tbl_Product_Licensor
Product_ID
Licensor_ID
Sublicensor_ID

A product will always have only one licensor, which may or may not
also have a sublicensor. How do I make this three field combo a unique
requirement when one can be null?

TIA...

Nov 12 '05 #2

P: n/a
rkc

"John" <so*********@hotmail.com> wrote in message
news:90**************************@posting.google.c om...
Any suggestions on how to get this to work:

My table includes a index that requires three combined fields to be
unique. However, sometimes the third field will be null....thereby
excluding the record from the uniqueness requirement.

Details:
tbl_Product_Licensor
Product_ID
Licensor_ID
Sublicensor_ID

A product will always have only one licensor, which may or may not
also have a sublicensor. How do I make this three field combo a unique
requirement when one can be null?


Can't you just set Required to no in the properties sheet?

You won't be able to enforce referential integrity for that field.

Nov 12 '05 #3

P: n/a
John wrote:
Any suggestions on how to get this to work:

My table includes a index that requires three combined fields to be
unique. However, sometimes the third field will be null....thereby
excluding the record from the uniqueness requirement.

Details:
tbl_Product_Licensor
Product_ID
Licensor_ID
Sublicensor_ID

A product will always have only one licensor, which may or may not
also have a sublicensor. How do I make this three field combo a unique
requirement when one can be null?

TIA...


If a product can only have 1 licensor, who cares what the sublicensor id
is except for informational purposes?

Personally, I would have an autonumber field called ProdLicID and make
it a primary key. I would index on Product and Licensor and maybe
SubLicensor fields. You could even make the indexes Unique if that
floats your boat.

The word that comes to mind with your scheme is PITA.

Nov 12 '05 #4

P: n/a
"Salad" <oi*@vinegar.com> wrote in message
news:tU******************@newsread2.news.pas.earth link.net...
John wrote:
Any suggestions on how to get this to work:

My table includes a index that requires three combined fields to be
unique. However, sometimes the third field will be null....thereby
excluding the record from the uniqueness requirement.

Details:
tbl_Product_Licensor
Product_ID
Licensor_ID
Sublicensor_ID

A product will always have only one licensor, which may or may not
also have a sublicensor. How do I make this three field combo a unique
requirement when one can be null?


Can't see the original post so I'll have to tag this onto Salad's reply.

Question is. What does it all mean? Frequently here people post questions
like this when it appears that the basic design is flawed.

A table in a database is usually the result of defining that purely
theoretical thing a relation which is usually the implementation of an
entity. So what does tbl_Product_Licensor represent. Mmmm....usually a table
with 2 ID columns is a junction table (let's ignore Sublicensor_ID for now)
which is the usual way to implement a many to many join, MEANING, in this
case that many products can have many licensors. But you say that isn't the
case. See what I'm talking about, it's the actual meaning in the problem
domain that you need to get sorted.

So if each product will always have only one licensor, why not:

tlbProduct
ProductID
more product stuff...
LicensorID (foreign key to tblLicensor)

Can a Licensor licence more than one product?

If not then the above isn't correct, and you probably need a one to one. Or
just a single table, including licensor data as well as product data.

If it is many to one, product to licensor, does each product ALWAYS have a
licensor (in which case LicenceID in tblProduct is not allowed null)?

What is a sub_licensor? What do they do? What is their real life
relationship to products and licensors? When we know that we might then have
some idea how to represent them in the database.

Mike

Nov 12 '05 #5

P: n/a
Thanks for the replies, and to Mike for the insightful response. There
is in fact a one-to-one relationship between a product and a licensor;
I will add a licensor_ID field into the product table instead of using
a juncture table. I kind of "inherited" bad data---a product would
occasionally have more than one licensor, which turned out to be
incorrect data.

Anyway, the product_id is really what will make the
product/relationship a unique record/relationship. I was just stuck
into a mindset of there being a many-to-many relationship based on the
(erroneous) data.

Thanks again...
Nov 12 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.