tags:

views:

43

answers:

1

Hi,

My website allows for anonymous sign-up of a mailing list. The same mailing list is also sent out to registered users.

The problem is when the anonymous user transitions to a registered user --- I don't want to spam the same email address twice.

My user table is as follow:

CREATE table users (

user_id  integer not null primary key,

email varchar(100) not null unique,

first_name varchar(100) not null,

last_name varchar(100) not null,

dont_spam_me_p char(1) default 'f' check (dont_spam_me_p in ('t','f')),

password  varchar(30) not null,

registration_date timestamp(0),

registration_ip  varchar(50) 

);

So how should I go about defining the mailing_list table?

+1  A: 

There's no reason to complicate your schema just to prevent duplicate delivery. When emailing your newsletter, collect all email addresses (from both anonymous and registered sources), remove the duplicates, and send the newsletter to each unique address.

Greg Hewgill
Good suggestion. I would do it in the database rather than the app. layer. What are your thoughts?
San Jacinto
A stored procedure or a view might be appropriate for solving this problem. A view might be the easiest to create and maintain.
Greg Hewgill