If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Avoiding data duplicate

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-01-11, 05:36
groove groove is offline
Registered User
 
Join Date: Jul 2011
Posts: 4
Avoiding data duplicate

I have a part table that stores parts data. the table looks like this (simplified version):
table part
id
partcode (this should be unique)
description

information about partcode can come from two or more different sources. let's say vendorACode, vendorBCode and vendorCCode catalogues.
It often happens that user refers to the same part using different part code. Let's say part P is identfied as x01 by vendorACode, y02 by vendorBCode, and z11 by vendorCCode catalogues (names are arbitrary).
So the problem is that user inputs part P using vendorACode catalogue. And another user inputs the same part using vendorBCode catalogue without knowing that data about part P is already stored in the table, resulting in data duplicate.

My immediate answer to this proble is to create another table that acts as an alias (part_alias), where one record in part table maps to one or several records in part_alias (one to many relationship).
How can I solve this problem ?
Any help would be greatly appreciated..
Reply With Quote
  #2 (permalink)  
Old 07-01-11, 05:45
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Quote:
Originally Posted by groove View Post
table part
id
partcode (this should be unique)
description
if you want partcode to be unique, all you have to do is ~make~ partcode unique by declaring a UNIQUE constraint on it

problem solved

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 07-06-11, 06:27
groove groove is offline
Registered User
 
Join Date: Jul 2011
Posts: 4
I'm afraid the solution is not that simple.. what if two unique values of partno refer to the same part (object)..??
Reply With Quote
  #4 (permalink)  
Old 07-06-11, 06:47
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,246
you can't have it both ways
Quote:
Originally Posted by groove View Post
partcode (this should be unique)
AND
Quote:
Originally Posted by groove View Post
I'm afraid the solution is not that simple.. what if two unique values of partno refer to the same part (object)..??
either partcode IS unique, or it isn't.
if it isn't then you may need to define another mechansim to make it unique. the only way I can see of doing that is if the partnumber is supplied from one or more suppliers and each supplier uses the same partcode for an equivalent part.

in that event the partcode would still be unique, but you would need a table to identify suppliers and an intersection tabel to associate suppliers with specific partcodes.


incidentally I'm surprised to find an ID column on what you pass off as a unique part, surely the partcode by itself is unique, or are you changing the rules (again), or merely being frugal with the business requirement
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #5 (permalink)  
Old 07-12-11, 09:48
weejas weejas is offline
Registered User
 
Join Date: Sep 2006
Location: Surrey, UK
Posts: 448
This is a standard business requirement. Our ERPS meets it with intersection tables that hold the SKU ID value, customer/supplier ID value and the third party's SKU ID value.

We also get around potential duplication of SKUs by only allowing one department to allocate and enrol new SKUs, but that's more of a business process than a feature of the database.
__________________
10% of magic is knowing something that no-one else does. The rest is misdirection.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On