Connecting Tech Pros Worldwide Forums | Help | Site Map

enum data type

Member
 
Join Date: Nov 2007
Posts: 125
#1: Oct 22 '08
hi,

can we have a enum datatype for a column in a table?
i need to store the position of an employee in the 'employee' table. there'll be just 5 positions available such as 'cashier, storage, admin, owner, etc..'.

for some reason i couldn't create another table to hold the position information and have a foreign key in the 'employee' table to that position table.

i thought i could use an enum data type. i want to hear from you guys, what datatype will suit this requirement. any comment and recommendation will be appreciated.

Thank you.

ck9663's Avatar
Expert
 
Join Date: Jun 2007
Posts: 1,925
#2: Oct 22 '08

re: enum data type


What error are you getting?

Try:

1. Create your POSITION table. Use tinyint as your PositionID (PK).
2. Insert records to your POSITION table.
3. Modify your EMPLOYEE table.Add a new column PositionID. Do not make it an FK yet.
4. Update your EMPLOYEE table for the proper PositionID based on POSITION table.
5. Make the Employee.PositionID as FK to Position.PositionID

Happy coding!

-- CK
Member
 
Join Date: Nov 2007
Posts: 125
#3: Oct 22 '08

re: enum data type


hi,

thanks for the reply.
actually the reason that i couldn't create the Position table is not because errors while creating the Position table, it's the customer demand. i think i'll try to discuss this with the customer.

Thank you.
Reply


Similar Microsoft SQL Server bytes