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 7520169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:01:11+00:00 2026-05-30T02:01:11+00:00

EDIT: My question was deficient because it was misunderstood. I’m rephrasing it. The original

  • 0

EDIT: My question was deficient because it was misunderstood. I’m rephrasing it. The original question is below the HR for the curious…

Given several SQL queries that operate on the same data, how can I assert in the type system, object model or test code that each possible row is selected by exactly one of the queries:

i.e. in this Venn diagram (thank you @Imre_L for the image) what is the best way to assert that queries A, B and U do not overlap?

enter image description here

Note the problem space is all possible data and not just the existing dataset.


The original question

I’m trying to devise a safe and easy to understand mechanism for composing a set of where clauses where the subsets of selected rows never overlap, yet execution of all clauses would select the set of all rows.

For example given a clause (in pseudo SQL) like:

... where name like 'Bob%'
and surname not like '%Smith' 
and postcode in (2000, 2010, 2020)

and another like

... where name in ('Alice', 'Jane')
and postcode < 9000
and married=True

and a final query to catch the remainder

... where not (name like 'Bob%' and surname not like '%Smith' and postcode in (2000, 2010, 2020))
and not (name in ('Alice', 'Jane') and postcode < 9000 and married=True)

How can I assert that each possible row is selected by exactly one of the possible queries?

My team is slowly migrating behaviour from one part of the system to another and need, at each stage, to alter the set of statements so that some rows selected by one statement are selected by a different one after the change. The assertion above needs to hold true before and after each change.

I’m looking for a neat solution for Java. Whether it’s checked in the type system, or controlled by some creation pattern or even checked during testing it doesn’t matter. I’m sure some boffins have some good ideas out there.

  • 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-30T02:01:12+00:00Added an answer on May 30, 2026 at 2:01 am

    This is wrong – the question is for all possible data.

    I am not sure I understand, but SQL includes union and distinct so you could check the count for:

    1. All queries unioned together

    2. All queries unioned together, distinct rows

    3. All rows in the table

    And they should all be equal. If you are missing a row completely then 2 will be less than 3; if you are duplicating a row anywhere then 2 will be less than 1.

    The queries for 1 and 2 would be:

    select count(*) from (
      select ....
      union [distinct]
      select ...
      union [distinct]
      ...)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit: original question below, but I revise it now that I have some code
edit #2: Question solved halfways. Look below As a follow-up question, does anyone know
[ Ed. Note: Related to this SO question ; didn't edit question because the
Edit: This question was written in 2008, which was like 3 internet ages ago.
EDIT: This question is more about language engineering than C++ itself. I used C++
EDIT : This question duplicates How to access the current Subversion build number? (Thanks
(EDIT: This question is now outdated for my particular issue, as Google Code supports
Edit This question has gone through a few iterations by now, so feel free
EDIT: This question is a duplicate of What is the difference between managed and
EDIT: This question was initially too general, I think. So What I really need

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.