Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: constraint question

Re: constraint question

From: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: Sun, 8 Sep 2002 22:05:04 +0200
Message-ID: <uno9qpk0alj55a@corp.supernews.com>

"eugene kim" <eugene1977_at_hotmail.com> wrote in message news:alfu81$3vd$1_at_newsreader.mailgate.org...
> hi..
> i'm a beginner sql programmer..
>
> if there's a better place to ask fundemantal sql questions like this..
> pls inform me,,
>
> my question is,
>
> create table teams(
> team_id integer primary key,
> school_id integer references schools,
> sport varchar(100),
> gender char
> );
>
> if ( school_id, sport, gender) uniquely identifies a team entity just like
> team_id can uniquely do so.
>
> is it better to have a constraint such as
> (school_id, sport, gender) unique
> in my table?
>
> well that will prevent users to insert duplicate data into table..
>
> so i guess it's better to have the constraint
> instead of forcing application programmer to check the condition..?
>
> thank you

Yes, it is because checking constraints in the application would mean the data is to be fetched to the client, and you will get a fat client. Also there is no explicit sql needed when checking declarative constraints.

Hth

--
Sybrand Bakker
Senior Oracle DBA

to reply remove '-verwijderdit' from my e-mail address
Received on Sun Sep 08 2002 - 15:05:04 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US