MySQL Forums
Forum List  »  Newbie

Re: Database abstraction: a abstract question
Posted by: David Fells
Date: April 11, 2005 08:36AM

This is simply called normalization =) It will reduce the amount of redundant data in your system and it will simplify the addition/deletion of those choices. Avoid ENUM and SET, those violate the most basic rules of normalization and make it difficult to change that data later. Simply store a 0 or a 1 when you need it. In this case though, there is no reason to store a yes/no response.

Quick example of tables...

CREATE TABLE Users (
userID INT AUTO_INCREMENT PRIMARY KEY,
...
);

CREATE TABLE Audiences (
audienceID INT AUTO_INCREMENT PRIMARY KEY,
...
);

CREATE TABLE Users_Audiences (
userID INT UNSIGNED NOT NULL,
audienceID INT UNSIGNED NOT NULL,
PRIMARY KEY (userID, audienceID)
);


This model assumes that a user can belong to multiple audiences. If they cannot, drop the Users_Audiences table and add the audienceID column to the Users table.

Options: ReplyQuote


Subject
Written By
Posted
Re: Database abstraction: a abstract question
April 11, 2005 08:36AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.