473,480 Members | 1,852 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Enumeration practicality

Assume you have an enumeration like PhoneType { Home, Business, Cell }.
This enumeration corresponds with a lookup/dictionary table in your database
like:

phone_cd | phone_descr
1 Home
2 Business
3 Cell

Now, I could associated each enumeration value with the phone_cd used in the
database. However, that strikes me as problematic ... it's like having two
copies of the same information in different places. However, otherwise I
need to be able translate between my enumeration values, and the database
values.

Is there a best practice(s) for dealing with this situation? Obviously it
depends on the circumstances, but general comments would be appreciated.
Thanks in advance.

Mark
Nov 16 '05 #1
2 1792
Mark,

I can't see why you would need it in more than one place. If you had a
number of details that you wanted to store for each id, then I would
recommend storing it in the database (with a column for each property you
want to store).

Either that, or I would use an enumeration in code, and attach
attributes to the enumeration which have the values that you want to store.
You can get the values from these attributes through reflection.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mark" <Ma**@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Assume you have an enumeration like PhoneType { Home, Business, Cell }.
This enumeration corresponds with a lookup/dictionary table in your
database
like:

phone_cd | phone_descr
1 Home
2 Business
3 Cell

Now, I could associated each enumeration value with the phone_cd used in
the
database. However, that strikes me as problematic ... it's like having
two
copies of the same information in different places. However, otherwise
I
need to be able translate between my enumeration values, and the database
values.

Is there a best practice(s) for dealing with this situation? Obviously it
depends on the circumstances, but general comments would be appreciated.
Thanks in advance.

Mark

Nov 16 '05 #2
Thanks Nicholas,

Are you suggesting that if I have a critical/obvious need to store the
code/description in the database, that I should likely only use the codes
(1, 2, 3) in the application rather than creating a corresponding
enumeration in my .NET code?

Thanks again.

Mark
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:OL**************@TK2MSFTNGP15.phx.gbl...
Mark,

I can't see why you would need it in more than one place. If you had a number of details that you wanted to store for each id, then I would
recommend storing it in the database (with a column for each property you
want to store).

Either that, or I would use an enumeration in code, and attach
attributes to the enumeration which have the values that you want to store. You can get the values from these attributes through reflection.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mark" <Ma**@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Assume you have an enumeration like PhoneType { Home, Business, Cell }.
This enumeration corresponds with a lookup/dictionary table in your
database
like:

phone_cd | phone_descr
1 Home
2 Business
3 Cell

Now, I could associated each enumeration value with the phone_cd used in
the
database. However, that strikes me as problematic ... it's like having
two
copies of the same information in different places. However, otherwise I
need to be able translate between my enumeration values, and the database values.

Is there a best practice(s) for dealing with this situation? Obviously it depends on the circumstances, but general comments would be appreciated.
Thanks in advance.

Mark


Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
12607
by: Justin Wright | last post by:
I know that I can set up an enumeration as follows ( just typed in quick so may have syntax errors ): <xsd:simpleType name="colors"> <xsd:restriction base="xsd:string"> <xsd:enumeration...
8
6493
by: aevans1108 | last post by:
Greetings I can't seem to inherit enumerated values from a globally defined type in my XML schema. XmlSchema.Compile() doesn't like it. Here's the schema. <?xml version="1.0"...
4
5638
by: Marshal | last post by:
Sure... IEnumerable was inconvenient suggesting a separate class to service the enumeration, IEnumerator, and multiple operations: Current, MoveNext, Reset. (I'll warp the definition of "operation"...
1
4964
by: Stefano G. | last post by:
I have a WSDL containing this enumeration type <xsd:simpleType name="item_type_enum"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="VCD"/> <xsd:enumeration value="SVCD"/>...
27
2633
by: Ben Finney | last post by:
Antoon Pardon wrote: > I just downloaded your enum module for python > and played a bit with it. IMO some of the behaviour makes it less > usefull. Feedback is appreciated. I'm hoping to...
3
2517
by: Davidoff | last post by:
Hi, I parse an XML file with a XSD schema. One XmlNode has an attribute whose type is a restriction of xs:string : <xs:simpleType name="stypeDay"> <xs:restriction base="xs:string">...
0
500
by: news.emn.fr | last post by:
Hello, i got this attribute <xs:attribute name="jour"> <xs:simpleType> <xs:restriction base="stypeJour"> </xs:restriction> </xs:simpleType> </xs:attribute>
3
2694
by: eXt | last post by:
For a realtime-application (half an application at least, kind of a framework) I am working with I need a event managing system and naturally it must be fast. I have defined a set of available...
3
4764
by: muler | last post by:
hi all, After reading this excerpt from "The C# Programming Language", (By Anders) I tried to check it out. Unfortunately, I'm getting compile errors. Can anyone illustrate this with an...
0
7054
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6918
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7057
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7102
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6756
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4798
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4495
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3000
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
570
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.