agora inbox for postgres@postgres.berkeley.edu  
help / color / mirror / Atom feed
how to define unique keys
2+ messages / 2 participants
[nested] [flat]

* how to define unique keys
@ 1994-05-05 21:56 Tom Wye <tjw00@spg.amdahl.com>
  1994-05-06 17:00 ` Re: how to define unique keys Paul M. Aoki <aoki@postgres.Berkeley.EDU>
  0 siblings, 1 reply; 2+ messages in thread

From: Tom Wye @ 1994-05-05 21:56 UTC (permalink / raw)
  To: legacy

I have a question about defining a unique key on a class.
It appears that the KEY operand on the create class command is not
implemented. Is this true? how does one create a class with a unique index?

Basically I want to have a class that has a unique index key that prevents
a duplicate index key from being added.

Thanks 

PS: you can email me at tjw00@spg.amdahl.com

===============================================================================
    To add/remove yourself from the POSTGRES mailing list: send mail with 
    the subject line ADD or DEL to "postgres-request@postgres.Berkeley.EDU"

    If this fails, send mail to "post_questions@postgres.Berkeley.EDU" and
    a human will deal with it.  DO NOT post to the "postgres" mailing list.
===============================================================================




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: how to define unique keys
  1994-05-05 21:56 how to define unique keys Tom Wye <tjw00@spg.amdahl.com>
@ 1994-05-06 17:00 ` Paul M. Aoki <aoki@postgres.Berkeley.EDU>
  0 siblings, 0 replies; 2+ messages in thread

From: Paul M. Aoki @ 1994-05-06 17:00 UTC (permalink / raw)
  To: Tom Wye <tjw00@spg.amdahl.com>; +Cc: legacy

tjw00@spg.amdahl.com (Tom Wye) writes:
> I have a question about defining a unique key on a class.
> It appears that the KEY operand on the create class command is not
> implemented. Is this true?

yup.

> how does one create a class with a unique index?

From: jpv@gavdos.pr.net.CH (Jean-Paul Vetterli)
To: postgres@postgres.Berkeley.EDU
Subject: Re: Managing key-value pairs
Resent-Date: Tue, 23 Nov 93 08:11:32 -0800

> From: dunkel@spin.chem.utah.edu (Reinhard Dunkel)
> Message-Id: <9311220311.AA21809@spin.chem.utah.edu>
> 
> [...]
> I am trying to use Postgres 4.1 (RS/6000-370, AIX 3.2.4) to manage
> key-value pairs for a graphical user interface. I am embarrassed to
> admit that I have problems to make this easiest of all database
> applications work smoothly. I would greatly appreciate any help on the
> following problems:
> 
> PROBLEM 1: I have to enforce that my "param" attribute values (keys)
> are unique in a database relation.  However, the command "create foo
> (param=char16, value=text) key (param)\g" is documented in the
> reference manual but the message "WARN:Nov 21 18:10:13:RelationCreate:
> KEY not yet supported" sounds discouraging. So before writing a
> key-value pair I query the database to see if the key is known and
> then either replace or append the tupel.  This approach takes two
> database accesses (one second overhead with libpq each). Is there a
> better way to do this?
> [...]

One approach to enforce uniqueness is to use rules. 
Example: 

---- cut here ----
#  this is a spog script: %spog -f <thisfile>
#  it is idempotent 
#
#  create key-value table:
create kv (k = char16,\
	v = text)
#
#  uniqueness *and* integrity:
define rule kv_r is \
	on append to kv \
	where kv.k = new.k or new.k ISNULL \
	do instead nothing
#
#  data:
append kv (k = "K1", v = "K1's value")
append kv (k = "K2", v = "K2's value")
append kv (k = "K3", v = "K3's value")
append kv (k = "K4", v = "K4's value")
append kv (k = "K5", v = "etc.")
---- cut here ----

I hope this can help.


Jean-Paul Vetterli 		
Route des Pommiers 19		email:	jpv@gavdos.pr.net.CH 		
CH-1723 Marly			phone:	++77 34 38 27 		
Switzerland			fax:	++37 46 53 09 
--
  Paul M. Aoki  |  CS Div., Dept. of EECS, UCB  |  aoki@postgres.Berkeley.EDU
                |  Berkeley, CA 94720           |  ...!uunet!ucbvax!aoki

===============================================================================
    To add/remove yourself from the POSTGRES mailing list: send mail with 
    the subject line ADD or DEL to "postgres-request@postgres.Berkeley.EDU"

    If this fails, send mail to "post_questions@postgres.Berkeley.EDU" and
    a human will deal with it.  DO NOT post to the "postgres" mailing list.
===============================================================================




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~1994-05-06 17:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1994-05-05 21:56 how to define unique keys Tom Wye <tjw00@spg.amdahl.com>
1994-05-06 17:00 ` Paul M. Aoki <aoki@postgres.Berkeley.EDU>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox