Hello

I have situation where I can't decide whether to use ENUM type.
Here is a situation:
table contains records about CarID and its colour(s). Each CarID is allowed to have 
more than one colour such as red, green, blue. CarID may have just one colour.
This is the code I would use to create table Colours:

CREATE TABLE Colours(
CarID INT UNSIGNED,
Colour ENUM("red", "green", "blue"),
PRIMARY KEY(CarID));

The question is- how can I create a record of a car that has more than one colour?
I also need to link my database with data entry interface, so interface has a tick 
boxes corresponding to all colours for a car.

Currently I have solved the situation this way:
there are three tables Colour, Car and Colours. Table Colour stores ColourID and 
ColourName; table Car stores CarID and CarName; table Colours stores CarID and 
ColourID, where the primary key is (ColourID, CarID). So I can have more than one 
colour (if there is a need for it) for one car.
I can easily pull out colours to the interface, so user is able to select 
corresponding colours.
Everything works just fine.


Is it a sensible approach not to use ENUM and create "transition" table such as above 
(Colours)? Which way is more efficient?

Your help will be very much appreciated.
Thanks.

Sergey.


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

  • ... "Николин Сергей"
    • ... tc lewis
    • ... Rolf Hopkins

Reply via email to