Jump to content

MySQL - Question about how and why to use enumerated data types

Whether you're a seasoned veteran or a struggling beginner, Web Radiance is the web development and web design forum for you. You'll find answers to all your HTML, CSS, SEO, and Programming needs. Pull up a chair and stay awhile.

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

MySQL - Question about how and why to use enumerated data types Rate Topic: -----

#1 User is offline   Beavis 

  • W.R. Corporal
  • Group: Members
  • Posts: 167
  • Joined: 24-March 08

Posted 10 July 2008 - 12:05 AM

As I understand it an enumerated data type is one where the allowable set of data input is
predefined as a set. For example if the field is "weather" - the enumerated set might be "hot,warm,cool,cold".

Question is, normally the input to such a field through a PHP form would only be restricted through a drop down list form element anyway,
so is there any real benefit in configuring a your database with an ENUM data type as opposed to a VARCHAR data type?
0

#2 User is offline   Karl Buckland 

  • A.K.A. Sirkent
  • Group: Administrators
  • Posts: 2,145
  • Joined: 04-April 06
  • Gender:Male
  • Location:Kent, UK

Posted 10 July 2008 - 03:34 AM

The only real benefit is that MySQL will maintain the integrity of your data for you. So you absolutely know that only one of the predetermined items can be in the field.
QUOTE(benbramz @ Aug 17 2007, 07:44 AM) Ive noticed that quite a few people are now adding quotes from the board into their signature. I think its started an new web-radiance craze.. :P
0

#3 User is offline   camal 

  • W.R. Private
  • Group: Members
  • Posts: 2
  • Joined: 10-December 08

Posted 10 December 2008 - 02:51 AM

Enumerated data type variables can only assume values which have been previously declared.
0

#4 User is offline   EncoderDecoder 

  • W.R. Sergeant
  • Group: Members
  • Posts: 260
  • Joined: 01-March 11
  • Gender:Female
  • Location:Philippines

Posted 17 May 2011 - 07:41 AM

also, it allows and promotes your code to be 'self-documenting'...
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users