You make a single explicit UniqueConstraint object that specifies all three.

Sent from my iPhone

> On Jul 30, 2014, at 2:30 PM, Rich Shepard <[email protected]> wrote:
> 
>> On Wed, 30 Jul 2014, Michael Bayer wrote:
>> 
>> Typically a UNIQUE constraint is placed on the "natural" key to prevent
>> dupes.
> 
>  I can see this when the natural key is a single column, but wonder how a
> compound natural key is represented if a serial integer is used as the
> surrogate 'id' key. For example,
> 
> class Changed_Data(Base):
>    __tablename__ = changed_data
> 
>    id = Column(Integer, primary_key = True)
>    which_table = Column(unicode(32), nullable = False)
>    which_attrib = Column(unicode(32), nullable = False)
>    when_changed = Column(Timestamp, nullable = False)
>    curr_value = Column(Unicode(32), nullable = False)
>    new_value = Column(Unicode(32), nullable = False)
>    changed_by = Column(Unicode(32), nullable = False)
>    reason = Column(Text)
> 
> The postgres schema specifies the primary key as (which_table,
> which_attribute, when_changed). If I make each of those columns Unique is it
> the set of columns that is unique or each individual column?
> 
> TIA,
> 
> Rich
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to