•
•
•
•
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 391,689 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 3,224 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:
Views: 400 | Replies: 1
![]() |
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
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
•
•
Join Date: Apr 2008
Posts: 295
Reputation:
Rep Power: 1
Solved Threads: 41
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
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.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Database Design Marketplace
Similar Threads
- beginner help (Java)
- Linked List (C++)
- Basic SQL made Hard (MS SQL)
- Seeking Project Manager in NJ/NY Metro Area (Web Development Job Offers)
- SQL Create table error (ASP.NET)
Other Threads in the Database Design Forum
- Previous Thread: where to store numerical rating?
- Next Thread: how to design this scenario contact for more than one entities


Linear Mode