Sorry you didn't understand what's I'm asking for.  It take some logical
thought to see the picture.  Now I know I will have to enforce it with
the application code (PHP, HTML and JavaScript) with the current two
column model.  Thanks for this idea....

 

Scott

 

________________________________

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 20, 2004 3:28 PM
To: Scott Fletcher
Cc: [EMAIL PROTECTED]
Subject: Re: How to make 1 primary key work for 2 columns????

 


I couldn't understand exactly what you were asking for. Did you want no
duplicates between columns or no duplicates between companies or what? 

This is something you will either enforce in your application code (with
your two column model) - OR - you will have to redesign your Primary and
Secondary storage to a single column (like your example).  Something
like this: 

CREATE TABLE contacts ( 
        company_ID int not null, 
        email_address varchar(255) not null, 
        email_type ENUM('primary', 'secondary') default 'primary' 
        Primary_key (company_ID, email_address) 
) 

The way I defined this primary key means that for any company, an email
address can appear only once. However, that email can be used for
multiple companies (a common sales person shared between smaller
businesses, for example). Do you want it so that an email is always
specific to only one company? Options abound. Please be more specific
about what rule you would like to enforce and we can help you write a
constraint that works for you. 

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine 

"Scott Fletcher" <[EMAIL PROTECTED]> wrote on 10/20/2004 03:54:12 PM:

> Hi!  I'm trying to figure out how to make this possible...  What I
have
> here is a company address, along with both the primary contact and
> secondary contact.  In them is one email address from the primary
> contact and one other email address from the secondary contact.
Problem
> is setting an unique primary key that treated the 2 columns as one
> column with unique email address.
> 
>  
> 
> Let's this example below
> 
>  
> 
>    --snip-
> 
>    |  First_Email  |  Second_Email  |
> 
>    ------------------------------------------------
> 
>    | [EMAIL PROTECTED]  | [EMAIL PROTECTED]      | 
> 
>    -----------------------------------------------
> 
>    | [EMAIL PROTECTED]  | [EMAIL PROTECTED]      |
> 
>    -----------------------------------------------
> 
> --snip-
> 
>  
> 
> be like this below where there is no two same email address....
> 
>  
> 
>    --snip-
> 
>     ---------------------------------------
> 
>     | [EMAIL PROTECTED]                   |
> 
>     ---------------------------------------
> 
>     | [EMAIL PROTECTED]                   |
> 
>     ---------------------------------------
> 
>     | [EMAIL PROTECTED]                   |
> 
>     ---------------------------------------
> 
>     | [EMAIL PROTECTED]                   |
> 
>     ---------------------------------------
> 
>    --snip-
> 
>  
> 
> Thanks,
> 
>  Scott
> 
>  
> 
>  
> 
>  
> 

Reply via email to