Enum or Int

Enum or Int

am 30.07.2004 11:48:59 von Salzgeber Olivier

Hello all

I have a table with a field which needs to hold a yes/no or 1/0 value.

Which field type is best for this ?
Should i create a ENUM field with yes or no values or is it better to create
an Int field for this ?

What would you recommend ?

Best regards
Olivier Salzgeber

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql@m.gmane.org

Re: Enum or Int

am 30.07.2004 14:14:57 von Cemal Dalar

There was a discussion about this topic at past. Check the previous posts.As
a simple answer they are technically the same. Use what ever you want..


Best Regards,
Cemal Dalar a.k.a Jimmy
System Administrator & Web Developer
http://www.dalar.net

----- Original Message -----
From: "Salzgeber Olivier"
To:
Sent: Friday, July 30, 2004 12:48 PM
Subject: Enum or Int


> Hello all
>
> I have a table with a field which needs to hold a yes/no or 1/0 value.
>
> Which field type is best for this ?
> Should i create a ENUM field with yes or no values or is it better to
create
> an Int field for this ?
>
> What would you recommend ?
>
> Best regards
> Olivier Salzgeber
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=cemal@dalar.net
>
>


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql@m.gmane.org

Re: Enum or Int

am 30.07.2004 22:55:06 von Michael Dykman

I hope I'm not opening an old can of worms here, but there are some
design trade-offs in this decision. ENUM has the strong advantage of
being able to constrain the contents to the specific expected values.
It is not possible for an application insert an illegal value whereas
using INT one would have to explicitly add a contraint to accomplish the
same thing . The drawback is that ENUM is not standard SQL making your
application non-portable to other RDBMS.

On Fri, 2004-07-30 at 08:14, Cemal Dalar wrote:
> There was a discussion about this topic at past. Check the previous posts.As
> a simple answer they are technically the same. Use what ever you want..
>
>
> Best Regards,
> Cemal Dalar a.k.a Jimmy
> System Administrator & Web Developer
> http://www.dalar.net
>
> ----- Original Message -----
> From: "Salzgeber Olivier"
> To:
> Sent: Friday, July 30, 2004 12:48 PM
> Subject: Enum or Int
>
>
> > Hello all
> >
> > I have a table with a field which needs to hold a yes/no or 1/0 value.
> >
> > Which field type is best for this ?
> > Should i create a ENUM field with yes or no values or is it better to
> create
> > an Int field for this ?
> >
> > What would you recommend ?
> >
> > Best regards
> > Olivier Salzgeber
> >
> > --
> > MySQL General Mailing List
> > For list archives: http://lists.mysql.com/mysql
> > To unsubscribe: http://lists.mysql.com/mysql?unsub=cemal@dalar.net
> >
> >
--
- michael dykman
- michael@dykman.org


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql@m.gmane.org

Re: Enum or Int

am 30.07.2004 23:02:36 von Keith Ivey

Michael Dykman wrote:

>I hope I'm not opening an old can of worms here, but there are some
>design trade-offs in this decision. ENUM has the strong advantage of
>being able to constrain the contents to the specific expected values.
>It is not possible for an application insert an illegal value whereas
>using INT one would have to explicitly add a contraint to accomplish the
>same thing .
>
You have essentially the same problem with ENUM:

| If you insert an invalid value into an |ENUM| (that is, a string not
present in the
| list of allowed values), the empty string is inserted instead as a
special error
| value. This string can be distinguished from a ``normal'' empty string
by the
| fact that this string has the numerical value 0.

See http://dev.mysql.com/doc/mysql/en/ENUM.html

--
Keith Ivey
Washington, DC


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql@m.gmane.org