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

Table design - PK - unique constraint?

Hello,

I have a junction table with composite PK on 3 fields...
[fldA], [fldB], [fldC]
I also need values to be unique across 4 values...
[fldA], [fldB], [fldC], [fldD]
I cant add the [fldD] column to the pk cause then 2 records could have the same data for [fldA], [fldB], [fldC], and that would be bad data.

Was going to add another unique constraint using all 4 fields.
Is that the best most efficent way to handle this?
Table will most likely have few records from 5 - 100.

Thanks!
Sep 28 '07 #1
2 1336
ck9663
2,878 Expert 2GB
Hello,

I have a junction table with composite PK on 3 fields...
[fldA], [fldB], [fldC]
I also need values to be unique across 4 values...
[fldA], [fldB], [fldC], [fldD]
I cant add the [fldD] column to the pk cause then 2 records could have the same data for [fldA], [fldB], [fldC], and that would be bad data.

Was going to add another unique constraint using all 4 fields.
Is that the best most efficent way to handle this?
Table will most likely have few records from 5 - 100.

Thanks!
i'll vote for YES.....
Sep 28 '07 #2
Sorry I did not ask my question properly.

Having a PK on fldA, fldB & fldC would ensure that fldA, fldB, fldC & fldD are always unique. So that makes my question silly the way i originally asked it.

Let me try again with a non generic example...

Composite PK is on Strategy, Type & Priority
So far everything is good they need to be unique.
Problem is that it would be considered bad data to have the Size field be the same as in the example below.

Strategy Type Priority Size
1 1 1 1

1 1 2 1

i cant just add Size to the PK cause then that would let there be a duplicate Priority like...

Strategy Type Priority Size
1 1 1 1

1 1 1 2

So i was thinking of keeping PK the way i have it on Strategy, Type & Priority
then adding a unique constraint on all 4 Strategy, Type & Priority, Size

now i can ask...
Is this the best & most efficent way to handle this situation or is there a better way to accomplish it?

Thanks!

ck9663 - I think your vote still applies, thanks for response - anyone else?
Sep 28 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: June Moore | last post by:
Hi, I would like to add a unique index that consists of two fields in a table. e.g. tbl_A (field1,field2) -- field1 & field2 Indexed and combination must be Unique. Can anyone tell me the...
10
by: Damien | last post by:
I have a table in my database called Users: CREATE TABLE ( NOT NULL CONSTRAINT DEFAULT (newid()), (20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , (40) COLLATE...
4
by: serge | last post by:
I ran into a table that is used a lot. Well less than 100,000 records. Maybe not a lot of records but i believe this table is used often. The table has 26 fields, 9 indexes but no Primary Key at...
1
by: Rajesh Kumar Mallah | last post by:
Hi , Looks like ADD UNIQUE( some_fuc( some_feild) ) is not supported with add constraint. the only way is to add the constriant is using UNIQUE INDEX . Is it a bug or intended behaviour? ...
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...
4
by: maricel | last post by:
I have the following base table structure - DDL: CREATE TABLE "ADMINISTRATOR"."T1" ( "C1" INTEGER NOT NULL ) IN "TEST_TS" ; ALTER TABLE "ADMINISTRATOR"."T1" ADD PRIMARY KEY
10
by: BuddhaBuddy | last post by:
Platform is DB2/NT 7.2.9 The table was created like this: CREATE TABLE MYTEST ( MYTESTOID bigint not null primary key, FK_OTHEROID bigint not null references other, FK_ANOTHEROID bigint not...
8
by: Rob Mazur | last post by:
Hi. I'm trying to create a query that pulls information from 3 seperate tables. Here's how I want it to work: User is prompted for SSN Table 1: SSN Name Gender
5
by: BerkshireGuy | last post by:
Hello everyone, I want to create an employee license plate database and need help with the best table design. I was thinking three tables: 1) tblEmployees EmployeeID EmployeeName
6
by: Kevin Chambers | last post by:
Hi all-- In an attempt to commit an Access MDB to a versioning system (subversion), I'm trying to figure out how to convert a jet table's metadata to text, a la SaveAsText. The end goal is to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...

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.