At DataDirect we often get XQuery coding questions from SQL programmers. It can probably be explained by two main reasons. First there are many developers with a SQL background, not surprising they are looking for some analogy with SQL during their first XQuery steps. Second, with DataDirect XQuery you can use XQuery against relational databases, DataDirect XQuery is a natural inroad for SQL programmers into the world of XML and XQuery.
As explained last week, we have good experiences teaching XQuery. I thought it would be a good idea to start a series “XQuery for the SQL programmer” – a light introduction to XQuery from a SQL perspective.This series is not a general introduction to XQuery. We assume you have already some notions of XQuery (or XPath). You can always refresh your XQuery knowledge reading Learn XQuery in 10 Minutes: An XQuery Tutorial. The following essays are available in this series. This list is updated as posts become available, bookmark it if you want to have the update-to-date and complete list at first hand.
- Introduction (this post)
- The Data Model
- Joining Data
- Operators, functions and conditions
- Grouping and aggregation
- Publishing data as XML
- Updating your database
- Using parameters
- Why XQuery?
- And performance?
USERS
ITEMS
BIDS
1 2 3 | SELECT ITEMNO FROM ITEMS WHERE DESCRIPTION = 'Motorcycle' |
1 2 3 | for $item in collection("ITEMS")/ITEMS where $item/DESCRIPTION = "Motorcycle" return $item/ITEMNO |
1 2 3 4 | SELECT ITEMNO FROM ITEMS WHERE DESCRIPTION = 'Motorcycle' ORDER BY ITEMNO |
1 2 3 4 | for $item in collection("ITEMS")/ITEMS where $item/DESCRIPTION = "Motorcycle" order by $item/ITEMNO return $item/ITEMNO |
Stay tuned!
