User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Database Design section within the Web Development category of DaniWeb, a massive community of 403,513 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,017 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Database Design advertiser: Programming Forums
Views: 418 | Replies: 1
Reply
Join Date: Apr 2007
Location: Nebraska
Posts: 1
Reputation: dakoris73 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
dakoris73's Avatar
dakoris73 dakoris73 is offline Offline
Newbie Poster

Help Understanding Constraints

  #1  
Jul 3rd, 2008
Hello there;

I have been trying to understand how contraints work, and how to apply them to my code, however, I just can't seem to grasp exactly how they work. Would it be possible for get some general info on HOW contraints work, and HOW to apply them to your code. in some of the examples I've seen, they have these constraints included, but everywhere I look, there's hardly any specific info on HOW to use these constraints.

Any help in clearing this fog in my mind about how to use these would be appreciated.

Thanks,
Mikey
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2008
Posts: 295
Reputation: tesuji is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 41
tesuji tesuji is offline Offline
Posting Whiz in Training

Re: Help Understanding Constraints

  #2  
Jul 3rd, 2008
Hi dakoris73

A constraint is kind of restriction usually to the range of values of a variable.
Given the following create-table statement we can detect several constraints:

create table raint(id integer UNIQUE, NOT NULL,
day char(10) CHECK(day IN ('Monday', 'Tuesday', 'wednesday', . . .) );

UNIQUE
This constraint assures that column id cannot contain duplicate values.

NOT NULL
This constraint requires that every insert-into statement of table raint
must also insert a value in column id not equal to NULL (NULL "value" indicates
that a column does not have a value stored)

CHECK()
This is a rather new and some more powerful constraint introduced with the SQL 1999 standard. Above is a mere simple example of a possible application.

Much more powerful constraints can be programmed by using the trigger concept
for what SQL standard has its own programming language (PSM).

I hope my annotations will create some clarification.

krs,
tesu
Last edited by tesuji : Jul 3rd, 2008 at 5:29 pm.
Information is moving—you know, nightly news is one way, of course, but it's also moving through the blogosphere and through the Internets. I promise you I will listen to what has been said here, even though I wasn't here. Ann and I will carry out this equivocal message to the world. I'm the master of low expectations.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Database Design Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Database Design Forum

All times are GMT -4. The time now is 12:54 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC