954,595 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Good Way to Have "Constants"

Hello,

I'm currently designing a simple movie database. In a table I have a column called status. And for that there will only be a few possibilities like "pending", "watched" etc...

What would be a good way to design it such that I have some kind of constant? Should I use integers, like 1="pending" 2="watched", or should I link it to another table? Or simply use strings?

Thanks.

Agent Cosmic
Junior Poster in Training
51 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

1. Add a check constraint with numbers only as value.
2. For the values refer to another column in some look up table.
3. In that table store the actual meaning of the numbers
i.e.-- 1="pending" 2="watched" etc..

debasisdas
Posting Genius
6,872 posts since Feb 2007
Reputation Points: 666
Solved Threads: 434
 

Some databases have enum values ( MySql and Postgresql both do) that are pretty much what @debasisdas suggested, but hide some of the complexity.

griswolf
Veteran Poster
1,165 posts since Apr 2010
Reputation Points: 344
Solved Threads: 256
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You