Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1054287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:22:52+00:00 2026-05-16T17:22:52+00:00

In my database course we use a book (Database System – the Complete Book)

  • 0

In my database course we use a book (Database System – the Complete Book) which says the following is a valid create table statement in standard SQL:

CREATE TABLE Participants (
    meetid INT NOT NULL,
    -- ...
    CONSTRAINT RoomConstraint
        CHECK (1 >= ALL (SELECT num FROM Numbers)
);

But DB2 complains and gives 20 possible explanations for why this statement fails.

So, does DB2 not support sub-queries in tuple-constraints? And if not, is a TRIGGER the only solution for enforcing the sub-query constraint?

Update: I’ve found this link which states it ain’t possible: http://bytes.com/topic/db2/answers/837390-can-constraint-replace-trigger

But again, is a TRIGGER the only way out? (I’m trying to enforce a relationship where a attribute can refer to two different tables (it ain’t my database))

Update 2: It does not work without ALL either:

CREATE TABLE Foo (
   meetid INT NOT NULL,
   CHECK (meetid IN (SELECT meetid FROM Foo)));

Update 3: The idea is that I want a foreign key which references two tables like the following:

Table Participants (pid, ...)
Table Rooms (room, ...)
Table People (userid, ...)

Essentially, a pid shall exists in either Rooms (attribute room) or in People (attribute userid). I could a part of this with a row constraint which checks whether pid is in Rooms or in People – but DB2 won’t let me. (I know there is a lot of other stuff to constrain for emulating the foreign key)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T17:22:54+00:00Added an answer on May 16, 2026 at 5:22 pm

    ALL() is not standard SQL** — it’s a T-SQL extension. DB2 does not support this.

    I’m not sure what you are trying to do with your constraint — it looks like you’re trying to ensure that every value of num in the Numbers table is less than or equal to 1. If this is actually the case, you should add a constraint on the Numbers table, not on Participants.

    **the SQL92 standard, and I don’t believe it was added to SQL99 or SQL2003

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 515k
  • Answers 515k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can box the int within an NSNumber. If your… May 16, 2026 at 6:29 pm
  • Editorial Team
    Editorial Team added an answer This is easily done via service overrides. May 16, 2026 at 6:29 pm
  • Editorial Team
    Editorial Team added an answer You misspoke in your question. You begin by saying the… May 16, 2026 at 6:29 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I am creating a database that will help keep track of which employees have
I have problems with my coredata sqlite DB, which hosts a book DB. After
I have a library, and I want to migrate it from an old system
A month ago I finished reading the book Art of Unit Testing and today
I know the basics of mySQL and database normalization. I am getting into Microsoft
Let's say I have some contrived models: class Author(Model): name = CharField() class Book(Model):
I have a collection of objects in a database. Images in a photo gallery,
In my ASP.NET web-application I use NHibernate to persist my User-Instances, where each of
I have an app that uses a database. At startup I check to see
Hey guys, I have a question about Sphinx. I use Sphinx to index the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.