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

Unique index and null values

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
5 1774
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
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
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
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Westcoast Sheri | last post by:
Which will be a faster lookup of an item by, "color" in the following mySQL tables: "unique key," "primary key," or just plain "key"?? CREATE TABLE myTable ( number int(11) NOT NULL default '0',...
26
by: Agoston Bejo | last post by:
I want to enforce such a constraint on a column that would ensure that the values be all unique, but this wouldn't apply to NULL values. (I.e. there may be more than one NULL value in the column.)...
3
by: Prince Kumar | last post by:
Is there any way I can define an Unique constraint or unique index which allows more than one null values for the same column combination in DB2? ie, If my index is defined on (col3, col4) where...
26
by: Agoston Bejo | last post by:
I want to enforce such a constraint on a column that would ensure that the values be all unique, but this wouldn't apply to NULL values. (I.e. there may be more than one NULL value in the column.)...
6
by: Alvin SIU | last post by:
Hi all, I have a table in Db2 v8 like this: Team Name Role ------ -------- --------------------- A Superman Leader A Batman Member A WonderWoman Member B ...
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: 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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...

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.