473,382 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

enumerated type..

hi,

Is it possible in Postgre to have enum type, so that later table fileld get values from 1-6 (saving space)

1 - statex
2 - stateY
3 - stateZ

something like that and then constrain on this enum type..

tia

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 23 '05 #1
2 1088
I don`t know, if there is a special feature in postgresql for this.
The standard SQL-way is to create a lookup-table and define a foreign-key to it.

create table states( state_id int primary key not null
, state_text varchar(30) not null
, constraint uk_states_state_text unique( state_text ) );
create table states( state_id int primary key not null , state_text varchar(30) not null );
alter table states add constraint uk_states_state_text unique( state_text );

create table your_table (
....
state_id int not null
, constraint fk_yt_state_id foreign key (state_id) references states
);


ra****@tvskat.net schrieb:
hi,

Is it possible in Postgre to have enum type, so that later table fileld get values from 1-6 (saving space)

1 - statex
2 - stateY
3 - stateZ

something like that and then constrain on this enum type..

tia

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 23 '05 #2
On Mon, Jul 19, 2004 at 16:46:08 +0200,
Michael Kleiser <mk*@webde-ag.de> wrote:
I don`t know, if there is a special feature in postgresql for this.
The standard SQL-way is to create a lookup-table and define a foreign-key
to it.


You could also use a domain which constrains one of its columns to a
few values. I don't think this would be appropiate for a large list,
like the list of use states. But you might do this when there are fewer
values and you don't expect the list to change.

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 23 '05 #3

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

Similar topics

0
by: Brandon | last post by:
Hello all, and thanks for taking a look at this. First off, the project I am working on is a server/client application that contains a shared assembly of common classes between the two...
2
by: Daniel Wilson | last post by:
I have an enumerated type like this: public __value enum MyType{ ABC = 1, DEF = 2, GHI = 3, JKL = 4 }; Later I have a for loop like this: for (ft = MyType::ABC; ft <= MyType::JKL; ft++){
22
by: Ben Finney | last post by:
Howdy all, I've recently packaged 'enum' in PyPI. In its description, I make the claim that it creates "immutable" enumeration objects, and that the enumeration values are "constant" values. ...
8
by: ypjofficial | last post by:
Hi all, In what way does the enumerated data type contibute to the size of a class if its part of that class? eg. #include <iostream.h> class one { public:
1
by: davidmcb | last post by:
I have defined an enumerated type that I use in various places in my schema. I am in the process of creating a new complex type that contains an attribute that I want to restrict to NOT being a...
4
by: Shawnk | last post by:
This post is intended to verify that true value semantics DO NOT EXIST for the Enum class (relative to boolean operations). If this is true then (thus and therefore) you can not design state...
0
by: jjoy | last post by:
After upgrading to 2.0/VS2005, one of the web services we consume no longer worked. It defines an enumerated type that is then used in several classes within the proxy code. The proxy code now...
7
by: John Goche | last post by:
Hello, The following program compiler and runs fine under gcc and produces the output 3. However, I am not sure whether such behavior is legal. In particular, as a related question, how would I...
1
by: senfo | last post by:
I'm using an enumerated type to identify a record type that relates to a unique ID in a database. Identity columns in SQL start at 1, while enumerated types in C# start at 0. I didn't think it...
11
by: David Mathog | last post by:
Is there a standard compliant method to access the number of elements in an enumerated type in C, either from within the preprocessor or the running program? The example below compiles and runs...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.