Questions tagged [relational-division]

Operation in relational algebra or in an RDBMS (mostly SQL) to partition relations. The inverse of a Cartesian product (CROSS JOIN in SQL).

E.F. Codd identified eight relational algebra operators in his defining paper "A Relational Model of Data for Large Shared Data Banks". Division is the least known and probably most complex of them. It is the inverse operation of a Cartesian product (CROSS JOIN in SQL).

It means partitioning a (bigger) table with rows from another (smaller) table. For requirements like:
"Find tuples that combine a particular value in one attribute with several values in another attribute."

A practical example for a setup with a many-to-many relationship between clubs and people:
"Find all clubs where Sue and John and James are members."

More information

467 questions
-2
votes
2 answers

Get Filtered columns from a table in SQL

I have a tabl1 with two columns (professors and the subjects they teach) and other table2 . Now I am trying to find out all the professors who can teach all the subjects in table2. I tried Join and Group by operations and got it successfully. But I…
Sandy K
  • 65
  • 1
  • 1
  • 8
-2
votes
2 answers

SQL query asking for the ids of students that took only sections that had more than 10 students in them

I have 2 tables enroll(sid, grade, dname, cno, sectno) and student(sid, sname, sex, age, year, gpa) I have to write query asking for the ids of students that took only sections that had more than 10 students in them. Why this query is not giving me…
Ahmed
  • 1
  • 1
-2
votes
4 answers

I got stuck in SQL select that has exactly multiple values

Table name: test id - student - class 1 - Jane - A 2 - David - B 3 - Jane - C 4 - Nick - A 5 - Nick - B 6 - Smith - C ---------------- Now I want to find out Student name that enrolled both A and C class (must be A and C) the result will show Jane…
-2
votes
5 answers

Simple but Impossible single MYSQL One to Many Query

Staff Table ID Name Gender 1 John Male 2 Adam Male 3 Joella Female Food Table ID StaffID Name 1 1 Eggs 2 1 Bacon 3 1 Toast 4 2 Eggs 5 2 Bacon 6 3 Toast I need the name of the MALE staff member who…
Kauffju3
  • 11
  • 3
-2
votes
2 answers

how to select database in this way - sql

i have this table id owner group model 1 1 shapes circle 2 1 shapes rectangle 3 1 shapes squire 4 2 fruits apple 5 2 fruits orange 6 2 fruits banana 7 …
-2
votes
3 answers

Translating a set theory idea into SQL

Say I have a the following db table: ╔═════════════════╦════════════╗ ║ ADVERTISEMENTID ║ CATEGORYID ║ ╠═════════════════╬════════════╣ ║ 1 ║ A ║ ║ 1 ║ C ║ ║ 2 ║ A ║ ║ …
balteo
  • 23,602
  • 63
  • 219
  • 412
-2
votes
1 answer

Logical conditional in PostgreSQL

I want the name of every male director that has directed more than 20 movies and has cast in every single movie he has directed. If he has cast a movie, but hasn't directed it, that's okay and I still want his name; if he has directed any movie but…
Phoexo
  • 2,485
  • 4
  • 25
  • 33
-3
votes
2 answers

Selecting ALL records when condition is met for ALL

I'm having a bit of trouble with getting a select statement to work correctly. I have the following tables: recipe recipe_ingredient pantry recipe1 ingredient1 Ingredient1 recipe1 ingredient2 Ingredient2 recipe2 ingredient3 I want a…
Platt90
  • 9
  • 1
-3
votes
2 answers

Select rows that meet ALL of a dynamic set of ids

I have a table that I want to be able to query to get rows that are in a defined sets of value. I can create new table structures if required as this is temporary data used for a leaderboard of sorts. The Token Sets can be created by grouping many…
userStack
  • 91
  • 7
-3
votes
2 answers

Stored procedure to get cutomer Ids on the basis of comma seperated value passed

Items Table: id item_name code cust_id 1 Mango 111 u1 2 Milk 112 u2 3 Chocolate 113 u3 4 Milk 112 u1 5 Mango 111 u2 6 Berry 114 u3 7 Chocolate 113 u1 8 Berry 114 u2 9 Ice-cream 114 u3 10 Mango 111 u4 These is the…
-3
votes
3 answers

How to get common value based on a column from a table sql

I have a table. the screenshot is given bellow: There have two columns item_details_id pay_method_id In item_details_id there have 1,2,1 data. On the other hand pay_method_id have 1,1,3 data. I want to get only common values of pay_method_id…
Mehedi Hasan Siam
  • 1,224
  • 3
  • 12
  • 28
-3
votes
2 answers

Getting common values in a table based on a subquery

I couldn't find what I am looking for even though it seems like a 'simple' thing to do in SQL. So here it is, I have a table containing dates and countries, let's call it A. I have a subquery that selects a list of countries from a table C, let's…
Simon
  • 41
  • 6
-3
votes
1 answer

Give the name of customers who bought ALL products with price less than 5

I want to write a query that give names of those customers only who have bought all products whose price is less than 5. Whereas, my query gives all customers who have bought even a single product whose price is less than 5. SELECT…
-3
votes
1 answer

Difference list vs INTERSECT across multiple tables

For a given database data structure: Table Attribute Type Glossary Species Sp_name C(10) P.K. Species name sp_woodtype C(10) Wood Yielded by tree …
-3
votes
2 answers

What is LINQ operator to perform division operation on Tables?

To select elements belonging to a particular group in Table, if elements and their group type are contained in one table and all group types are listed in another table we perform division on tables. I am trying LINQ query to perform the same…
Maruthi Revankar
  • 331
  • 2
  • 5
  • 17
1 2 3
31
32