Answers.Body: <p>Learning the algebraic nature of SQL will certainly help you master it.</p>
  <p>A number of warnings though.</p>
  <p>First, &quot;relational algebra&quot; when referred to in the academic sense - typically meaning the theory as devised by EF Codd across the 1970s - does not fully correspond to SQL today or explain all parts of it.</p>
  <p>It is better to think of SQL as based upon or inspired by Codd's original work. My own opinion nowadays is that SQL also draws some conceptual inspiration from the work of KE Iverson and his language APL - a colleague of Codd's at IBM. At any rate, we are several decades along now.</p>
  <p>Second, even when Codd's relational algebra is being taught, it often isn't taught well in my opinion.</p>
  <p>Codd's own writings are probably the best sources on Codd, but they are relatively brief and clearly speak to expert computer scientists who would have understood a great deal tacitly - I don't know how someone unfamiliar with SQL would fare in interpreting them.</p>
  <p>Another more particular problem about Codd's RA is that it is often not taught well in a way that actual or would-be SQL practitioners would find useful, and will often make claims about RA which are false and misleading about SQL.</p>
  <p>Most prominent amongst these, in my opinion, are the claims that SQL works with sets, and that those sets are (by definition) unordered. In fact, SQL works with so-called &quot;bags&quot; or &quot;multi-sets&quot; from a theoretical perspective, and the stored data is very often ordered but SQL operators are lax and inconsistent about preserving a particular order (in ways that defy simple summary, and for reasons that require deep explanation).</p>
  <p>Third, there are dialectical differences between different SQL engines and vendors. These dialectical differences can concern both syntax and actual functionality.</p>
  <p>There are also a number of operators in modern SQL which have no real analogy at all in Codd's RA, but do fit better into the more general framework of Iverson.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-07-29T10:13:18.737Z
Answers.LastActivityDate: 2023-07-29T10:13:18.737Z
Answers.UserDisplayName: Steve
Answers.Body: <p>You can find the official tutorial on SQL subqueries at: <a href="https://beginner-sql-tutorial.com/sql-subquery.htm" rel="nofollow noreferrer">https://beginner-sql-tutorial.com/sql-subquery.htm</a>. The explanation there seems clear enough.</p>
  <p>However, I found that understanding both Relational Algebra and Relational Calculus to be very helpful in understanding the underlying structures behind relational databases and SQL in general.</p>
  <p>If SQL is important to your studies or career, either or both of Relational Algebra and Relational Calculus should be a help as is some understanding of Entity Relationship design process.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-07-20T14:21:08.757Z
Answers.LastActivityDate: 2023-07-20T14:21:08.757Z
Answers.UserDisplayName: Buffy
Body: <p>I'm finding SQL subqueries tough to understand and write.</p>
  <p>When I ask how I can make it easier to write subqueries, the first response people give is &quot;practice&quot;. But what do I practice? Where do I practice subqueries?</p>
  <p>HackerRank problems are tough for my level. What are places who teach and practice subqueries?</p>
  <p>Will learning relational algebra and calculus help me to learn SQL subqueries?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-09-04T17:01:53.150Z
Comments.Text: [Is there any rule of thumb to construct SQL query from a human-readable description?](https://stackoverflow.com/a/33952141/3404097) [An Introduction to Relational Database Theory](https://bookboon.com/en/an-introduction-to-relational-database-theory-ebook) 
  [SQL: A Comparative Survey](https://bookboon.com/en/sql-a-comparative-survey-ebook) ) [Exercises on Relational Database Theory](https://bookboon.com/en/exercises-on-relational-database-theory-ebook)
Comments.UserDisplayName: philipxy
Tags: <self-learning><databases><sql>
Title: Will learning relational algebra and calculus help me to learn SQL subqueries?
ThreadText: # Will learning relational algebra and calculus help me to learn SQL subqueries?
  
  (Asked by: username_0 on 2023-07-18)
  
  I'm finding SQL subqueries tough to understand and write.
  
  When I ask how I can make it easier to write subqueries, the first response people give is "practice". But what do I practice? Where do I practice subqueries?
  
  HackerRank problems are tough for my level. What are places who teach and practice subqueries?
  
  Will learning relational algebra and calculus help me to learn SQL subqueries?
  
  **Tags:** self-learning, databases, sql
  
  > **Comments:**
  > **username_1**: [Is there any rule of thumb to construct SQL query from a human-readable description?](https://stackoverflow.com/a/33952141/3404097) [An Introduction to Relational Database Theory](https://bookboon.com/en/an-introduction-to-relational-database-theory-ebook)  [SQL: A Comparative Survey](https://bookboon.com/en/sql-a-comparative-survey-ebook) ) [Exercises on Relational Database Theory](https://bookboon.com/en/exercises-on-relational-database-theory-ebook)  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2023-07-29. Score: 2
  
  Learning the algebraic nature of SQL will certainly help you master it.
  
  A number of warnings though.
  
  First, "relational algebra" when referred to in the academic sense - typically meaning the theory as devised by EF Codd across the 1970s - does not fully correspond to SQL today or explain all parts of it.
  
  It is better to think of SQL as based upon or inspired by Codd's original work. My own opinion nowadays is that SQL also draws some conceptual inspiration from the work of KE Iverson and his language APL - a colleague of Codd's at IBM. At any rate, we are several decades along now.
  
  Second, even when Codd's relational algebra is being taught, it often isn't taught well in my opinion.
  
  Codd's own writings are probably the best sources on Codd, but they are relatively brief and clearly speak to expert computer scientists who would have understood a great deal tacitly - I don't know how someone unfamiliar with SQL would fare in interpreting them.
  
  Another more particular problem about Codd's RA is that it is often not taught well in a way that actual or would-be SQL practitioners would find useful, and will often make claims about RA which are false and misleading about SQL.
  
  Most prominent amongst these, in my opinion, are the claims that SQL works with sets, and that those sets are (by definition) unordered. In fact, SQL works with so-called "bags" or "multi-sets" from a theoretical perspective, and the stored data is very often ordered but SQL operators are lax and inconsistent about preserving a particular order (in ways that defy simple summary, and for reasons that require deep explanation).
  
  Third, there are dialectical differences between different SQL engines and vendors. These dialectical differences can concern both syntax and actual functionality.
  
  There are also a number of operators in modern SQL which have no real analogy at all in Codd's RA, but do fit better into the more general framework of Iverson.
  
  
  ---
  
  ### Answer by username_3 on 2023-07-20. Score: 1
  
  You can find the official tutorial on SQL subqueries at: <https://beginner-sql-tutorial.com/sql-subquery.htm>. The explanation there seems clear enough.
  
  However, I found that understanding both Relational Algebra and Relational Calculus to be very helpful in understanding the underlying structures behind relational databases and SQL in general.
  
  If SQL is important to your studies or career, either or both of Relational Algebra and Relational Calculus should be a help as is some understanding of Entity Relationship design process.
  
  
  ---
  
  