Despite the NoSQL movement trying to flag traditional databases as a dying breed, the RDBMS keeps evolving and adding new powerful weapons to its arsenal. In this talk we'll explore Common Table Expressions (SQL-99) and how SQL handles recursion, breaking the bi-dimensional barriers and paving the way to more complex data structures like trees and graphs, and how we can replicate features from social networks and recommendation systems. We'll also have a look at window functions (SQL:2003) and the advanced reporting features they make finally possible.
Trees In The Database - Advanced data structuresLorenzo Alberton
Storing tree structures in a bi-dimensional table has always been problematic. The simplest tree models are usually quite inefficient, while more complex ones aren't necessarily better. In this talk I briefly go through the most used models (adjacency list, materialized path, nested sets) and introduce some more advanced ones belonging to the nested intervals family (Farey algorithm, Continued Fractions, and other encodings). I describe the advantages and pitfalls of each model, some proprietary solutions (e.g. Oracle's CONNECT BY) and one of the SQL Standard's upcoming features, Common Table Expressions.
Presentation given at OSCON 2009 and PostgreSQL West 09. Describes SQL solutions to a selection of object-oriented problems:
- Extensibility
- Polymorphism
- Hierarchies
- Using ORM in MVC application architecture
These slides are excerpted from another presentation, "SQL Antipatterns Strike Back."
MySQL 8 introduces support for ANSI SQL recursive queries with common table expressions, a powerful method for working with recursive data references. Until now, MySQL application developers have had to use workarounds for hierarchical data relationships. It's time to write SQL queries in a more standardized way, and be compatible with other brands of SQL implementations. But as always, the bottom line is: how does it perform? This presentation will briefly describe how to use recursive queries, and then test the performance and scalability of those queries against other solutions for hierarchical queries.
Debugging PySpark: Spark Summit East talk by Holden KarauSpark Summit
Apache Spark is one of the most popular big data projects, offering greatly improved performance over traditional MapReduce models. Much of Apache Spark’s power comes from lazy evaluation along with intelligent pipelining, which can make debugging more challenging. This talk will examine how to debug Apache Spark applications, the different options for logging in Spark’s variety of supported languages, as well as some common errors and how to detect them.
Spark’s own internal logging can often be quite verbose, and this talk will examine how to effectively search logs from Apache Spark to spot common problems. In addition to the internal logging, this talk will look at options for logging from within our program itself.
Spark’s accumulators have gotten a bad rap because of how they interact in the event of cache misses or partial recomputes, but this talk will look at how to effectively use Spark’s current accumulators for debugging as well as a look to future for data property type accumulators which may be coming to Spark in future version.
In addition to reading logs, and instrumenting our program with accumulators, Spark’s UI can be of great help for quickly detecting certain types of problems.
Join operations in Apache Spark is often the biggest source of performance problems and even full-blown exceptions in Spark. After this talk, you will understand the two most basic methods Spark employs for joining DataFrames – to the level of detail of how Spark distributes the data within the cluster. You’ll also find out how to work out common errors and even handle the trickiest corner cases we’ve encountered! After this talk, you should be able to write performance joins in Spark SQL that scale and are zippy fast!
This session will cover different ways of joining tables in Apache Spark.
Speaker: Vida Ha
This talk was originally presented at Spark Summit East 2017.
Trees In The Database - Advanced data structuresLorenzo Alberton
Storing tree structures in a bi-dimensional table has always been problematic. The simplest tree models are usually quite inefficient, while more complex ones aren't necessarily better. In this talk I briefly go through the most used models (adjacency list, materialized path, nested sets) and introduce some more advanced ones belonging to the nested intervals family (Farey algorithm, Continued Fractions, and other encodings). I describe the advantages and pitfalls of each model, some proprietary solutions (e.g. Oracle's CONNECT BY) and one of the SQL Standard's upcoming features, Common Table Expressions.
Presentation given at OSCON 2009 and PostgreSQL West 09. Describes SQL solutions to a selection of object-oriented problems:
- Extensibility
- Polymorphism
- Hierarchies
- Using ORM in MVC application architecture
These slides are excerpted from another presentation, "SQL Antipatterns Strike Back."
MySQL 8 introduces support for ANSI SQL recursive queries with common table expressions, a powerful method for working with recursive data references. Until now, MySQL application developers have had to use workarounds for hierarchical data relationships. It's time to write SQL queries in a more standardized way, and be compatible with other brands of SQL implementations. But as always, the bottom line is: how does it perform? This presentation will briefly describe how to use recursive queries, and then test the performance and scalability of those queries against other solutions for hierarchical queries.
Debugging PySpark: Spark Summit East talk by Holden KarauSpark Summit
Apache Spark is one of the most popular big data projects, offering greatly improved performance over traditional MapReduce models. Much of Apache Spark’s power comes from lazy evaluation along with intelligent pipelining, which can make debugging more challenging. This talk will examine how to debug Apache Spark applications, the different options for logging in Spark’s variety of supported languages, as well as some common errors and how to detect them.
Spark’s own internal logging can often be quite verbose, and this talk will examine how to effectively search logs from Apache Spark to spot common problems. In addition to the internal logging, this talk will look at options for logging from within our program itself.
Spark’s accumulators have gotten a bad rap because of how they interact in the event of cache misses or partial recomputes, but this talk will look at how to effectively use Spark’s current accumulators for debugging as well as a look to future for data property type accumulators which may be coming to Spark in future version.
In addition to reading logs, and instrumenting our program with accumulators, Spark’s UI can be of great help for quickly detecting certain types of problems.
Join operations in Apache Spark is often the biggest source of performance problems and even full-blown exceptions in Spark. After this talk, you will understand the two most basic methods Spark employs for joining DataFrames – to the level of detail of how Spark distributes the data within the cluster. You’ll also find out how to work out common errors and even handle the trickiest corner cases we’ve encountered! After this talk, you should be able to write performance joins in Spark SQL that scale and are zippy fast!
This session will cover different ways of joining tables in Apache Spark.
Speaker: Vida Ha
This talk was originally presented at Spark Summit East 2017.
Change Data Feed is a new feature of Delta Lake on Databricks that is available as a public preview since DBR 8.2. This feature enables a new class of ETL workloads such as incremental table/view maintenance and change auditing that were not possible before. In short, users will now be able to query row level changes across different versions of a Delta table.
In this talk we will dive into how Change Data Feed works under the hood and how to use it with existing ETL jobs to make them more efficient and also go over some new workloads it can enable.
Overview of tools available in python for performing data visualization (statistical, geographical, reporting, etc). Prepared for Minsk DataViz Day (October 4, 2017)
Designing ETL Pipelines with Structured Streaming and Delta Lake—How to Archi...Databricks
Structured Streaming has proven to be the best platform for building distributed stream processing applications. Its unified SQL/Dataset/DataFrame APIs and Spark’s built-in functions make it easy for developers to express complex computations. Delta Lake, on the other hand, is the best way to store structured data because it is a open-source storage layer that brings ACID transactions to Apache Spark and big data workloads Together, these can make it very easy to build pipelines in many common scenarios. However, expressing the business logic is only part of the larger problem of building end-to-end streaming pipelines that interact with a complex ecosystem of storage systems and workloads. It is important for the developer to truly understand the business problem that needs to be solved. Apache Spark, being a unified analytics engine doing both batch and stream processing, often provides multiples ways to solve the same problem. So understanding the requirements carefully helps you to architect your pipeline that solves your business needs in the most resource efficient manner.
In this talk, I am going examine a number common streaming design patterns in the context of the following questions.
WHAT are you trying to consume? What are you trying to produce? What is the final output that the business wants? What are your throughput and latency requirements?
WHY do you really have those requirements? Would solving the requirements of the individual pipeline actually solve your end-to-end business requirements?
HOW are going to architect the solution? And how much are you willing to pay for it?
Clarity in understanding the ‘what and why’ of any problem can automatically much clarity on the ‘how’ to architect it using Structured Streaming and, in many cases, Delta Lake.
A Deep Dive into Spark SQL's Catalyst Optimizer with Yin HuaiDatabricks
Catalyst is becoming one of the most important components of Apache Spark, as it underpins all the major new APIs in Spark 2.0 and later versions, from DataFrames and Datasets to Streaming. At its core, Catalyst is a general library for manipulating trees.
In this talk, Yin explores a modular compiler frontend for Spark based on this library that includes a query analyzer, optimizer, and an execution planner. Yin offers a deep dive into Spark SQL’s Catalyst optimizer, introducing the core concepts of Catalyst and demonstrating how developers can extend it. You’ll leave with a deeper understanding of how Spark analyzes, optimizes, and plans a user’s query.
A comparison of different solutions for full-text search in web applications using PostgreSQL and other technology. Presented at the PostgreSQL Conference West, in Seattle, October 2009.
Traditionally database systems were optimized either for OLAP either for OLTP workloads. Such mainstream DBMSes like Postgres,MySQL,... are mostly used for OLTP, while Greenplum, Vertica, Clickhouse, SparkSQL,... are oriented on analytic queries. But right now many companies do not want to have two different data stores for OLAP/OLTP and need to perform analytic queries on most recent data. I want to discuss which features should be added to Postgres to efficiently handle HTAP workload.
Pyspark Tutorial | Introduction to Apache Spark with Python | PySpark Trainin...Edureka!
** PySpark Certification Training: https://www.edureka.co/pyspark-certification-training**
This Edureka tutorial on PySpark Tutorial will provide you with a detailed and comprehensive knowledge of Pyspark, how it works, the reason why python works best with Apache Spark. You will also learn about RDDs, data frames and mllib.
MySQL Workbench Tutorial | Introduction To MySQL Workbench | MySQL DBA Traini...Edureka!
** MYSQL DBA Certification Training https://www.edureka.co/mysql-dba **
This Edureka tutorial on MySQL Workbench explains all the fundamentals of MySQL Workbench with examples.
The following are the topics covered in this tutorial:
What is MySQL Workbench?
MySQL Workbench Functionaltites
MySQL Workbench Editions
The Three Modules of Workbench
1. SQL Development
2. Data Modelling
3. Migration Wizard
Data Import & Export
Subscribe to our Edureka YouTube channel and hit the bell icon to get video updates: https://goo.gl/6ohpT
Follow us to never miss an update in the future.
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
It's Time To Stop Using Lambda Architecture | Yaroslav Tkachenko, ShopifyHostedbyConfluent
Lambda Architecture has been a common way to build data pipelines for a long time, despite difficulties in maintaining two complex systems. An alternative, Kappa Architecture, was proposed in 2014, but many companies are still reluctant to switch to Kappa. And there is a reason for that: even though Kappa generally provides a simpler design and similar or lower latency, there are a lot of practical challenges in areas like exactly-once delivery, late-arriving data, historical backfill and reprocessing.
In this talk, I want to show how you can solve those challenges by embracing Apache Kafka as a foundation of your data pipeline and leveraging modern stream-processing frameworks like Apache Kafka Streams and Apache Flink.
Clickhouse Capacity Planning for OLAP Workloads, Mik Kocikowski of CloudFlareAltinity Ltd
Presented on December ClickHouse Meetup. Dec 3, 2019
Concrete findings and "best practices" from building a cluster sized for 150 analytic queries per second on 100TB of http logs. Topics covered: hardware, clients (http vs native), partitioning, indexing, SELECT vs INSERT performance, replication, sharding, quotas, and benchmarking.
Monitoring at scale - Intuitive dashboard designLorenzo Alberton
At a certain scale, millions of events happen every second, and all of them are important to evaluate the health of the system. If not handled correctly, such a volume of information can overwhelm both the infrastructure that needs to support them, and people who have to make a sense out of thousands of signals and make decisions upon them, fast. By understanding how our rational mind works, how people process information, we can present data so it's more evident and intuitive. This talk will explain how to collect useful metrics, and to create the perfect monitoring dashboard to organise and display them, letting our intuition operate automatically and quickly, and saving attention and mental effort to activities that demand it.
Change Data Feed is a new feature of Delta Lake on Databricks that is available as a public preview since DBR 8.2. This feature enables a new class of ETL workloads such as incremental table/view maintenance and change auditing that were not possible before. In short, users will now be able to query row level changes across different versions of a Delta table.
In this talk we will dive into how Change Data Feed works under the hood and how to use it with existing ETL jobs to make them more efficient and also go over some new workloads it can enable.
Overview of tools available in python for performing data visualization (statistical, geographical, reporting, etc). Prepared for Minsk DataViz Day (October 4, 2017)
Designing ETL Pipelines with Structured Streaming and Delta Lake—How to Archi...Databricks
Structured Streaming has proven to be the best platform for building distributed stream processing applications. Its unified SQL/Dataset/DataFrame APIs and Spark’s built-in functions make it easy for developers to express complex computations. Delta Lake, on the other hand, is the best way to store structured data because it is a open-source storage layer that brings ACID transactions to Apache Spark and big data workloads Together, these can make it very easy to build pipelines in many common scenarios. However, expressing the business logic is only part of the larger problem of building end-to-end streaming pipelines that interact with a complex ecosystem of storage systems and workloads. It is important for the developer to truly understand the business problem that needs to be solved. Apache Spark, being a unified analytics engine doing both batch and stream processing, often provides multiples ways to solve the same problem. So understanding the requirements carefully helps you to architect your pipeline that solves your business needs in the most resource efficient manner.
In this talk, I am going examine a number common streaming design patterns in the context of the following questions.
WHAT are you trying to consume? What are you trying to produce? What is the final output that the business wants? What are your throughput and latency requirements?
WHY do you really have those requirements? Would solving the requirements of the individual pipeline actually solve your end-to-end business requirements?
HOW are going to architect the solution? And how much are you willing to pay for it?
Clarity in understanding the ‘what and why’ of any problem can automatically much clarity on the ‘how’ to architect it using Structured Streaming and, in many cases, Delta Lake.
A Deep Dive into Spark SQL's Catalyst Optimizer with Yin HuaiDatabricks
Catalyst is becoming one of the most important components of Apache Spark, as it underpins all the major new APIs in Spark 2.0 and later versions, from DataFrames and Datasets to Streaming. At its core, Catalyst is a general library for manipulating trees.
In this talk, Yin explores a modular compiler frontend for Spark based on this library that includes a query analyzer, optimizer, and an execution planner. Yin offers a deep dive into Spark SQL’s Catalyst optimizer, introducing the core concepts of Catalyst and demonstrating how developers can extend it. You’ll leave with a deeper understanding of how Spark analyzes, optimizes, and plans a user’s query.
A comparison of different solutions for full-text search in web applications using PostgreSQL and other technology. Presented at the PostgreSQL Conference West, in Seattle, October 2009.
Traditionally database systems were optimized either for OLAP either for OLTP workloads. Such mainstream DBMSes like Postgres,MySQL,... are mostly used for OLTP, while Greenplum, Vertica, Clickhouse, SparkSQL,... are oriented on analytic queries. But right now many companies do not want to have two different data stores for OLAP/OLTP and need to perform analytic queries on most recent data. I want to discuss which features should be added to Postgres to efficiently handle HTAP workload.
Pyspark Tutorial | Introduction to Apache Spark with Python | PySpark Trainin...Edureka!
** PySpark Certification Training: https://www.edureka.co/pyspark-certification-training**
This Edureka tutorial on PySpark Tutorial will provide you with a detailed and comprehensive knowledge of Pyspark, how it works, the reason why python works best with Apache Spark. You will also learn about RDDs, data frames and mllib.
MySQL Workbench Tutorial | Introduction To MySQL Workbench | MySQL DBA Traini...Edureka!
** MYSQL DBA Certification Training https://www.edureka.co/mysql-dba **
This Edureka tutorial on MySQL Workbench explains all the fundamentals of MySQL Workbench with examples.
The following are the topics covered in this tutorial:
What is MySQL Workbench?
MySQL Workbench Functionaltites
MySQL Workbench Editions
The Three Modules of Workbench
1. SQL Development
2. Data Modelling
3. Migration Wizard
Data Import & Export
Subscribe to our Edureka YouTube channel and hit the bell icon to get video updates: https://goo.gl/6ohpT
Follow us to never miss an update in the future.
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
It's Time To Stop Using Lambda Architecture | Yaroslav Tkachenko, ShopifyHostedbyConfluent
Lambda Architecture has been a common way to build data pipelines for a long time, despite difficulties in maintaining two complex systems. An alternative, Kappa Architecture, was proposed in 2014, but many companies are still reluctant to switch to Kappa. And there is a reason for that: even though Kappa generally provides a simpler design and similar or lower latency, there are a lot of practical challenges in areas like exactly-once delivery, late-arriving data, historical backfill and reprocessing.
In this talk, I want to show how you can solve those challenges by embracing Apache Kafka as a foundation of your data pipeline and leveraging modern stream-processing frameworks like Apache Kafka Streams and Apache Flink.
Clickhouse Capacity Planning for OLAP Workloads, Mik Kocikowski of CloudFlareAltinity Ltd
Presented on December ClickHouse Meetup. Dec 3, 2019
Concrete findings and "best practices" from building a cluster sized for 150 analytic queries per second on 100TB of http logs. Topics covered: hardware, clients (http vs native), partitioning, indexing, SELECT vs INSERT performance, replication, sharding, quotas, and benchmarking.
Monitoring at scale - Intuitive dashboard designLorenzo Alberton
At a certain scale, millions of events happen every second, and all of them are important to evaluate the health of the system. If not handled correctly, such a volume of information can overwhelm both the infrastructure that needs to support them, and people who have to make a sense out of thousands of signals and make decisions upon them, fast. By understanding how our rational mind works, how people process information, we can present data so it's more evident and intuitive. This talk will explain how to collect useful metrics, and to create the perfect monitoring dashboard to organise and display them, letting our intuition operate automatically and quickly, and saving attention and mental effort to activities that demand it.
Modern Algorithms and Data Structures - 1. Bloom Filters, Merkle TreesLorenzo Alberton
The first part of a series of talks about modern algorithms and data structures, used by nosql databases like HBase and Cassandra. An explanation of Bloom Filters and several derivates, and Merkle Trees.
The ability to grow (and shrink) according to the needs and the available resources is an essential part of designing applications. In this talk we'll cover the fundamental elements of scalability, including aspects involving people, processes and technology. With sound and proven principles and some advice on how to shape your organisation, set the right processes and design your application, this session is a must-see for developers and technical leads alike.
NoSQL databases get a lot of press coverage, but there seems to be a lot of confusion surrounding them, as in which situations they work better than a Relational Database, and how to choose one over another. This talk will give an overview of the NoSQL landscape and a classification for the different architectural categories, clarifying the base concepts and the terminology, and will provide a comparison of the features, the strengths and the drawbacks of the most popular projects (CouchDB, MongoDB, Riak, Redis, Membase, Neo4j, Cassandra, HBase, Hypertable).
Lecture 2: Data-Intensive Computing for Text Analysis (Fall 2011)Matthew Lease
Data-Intensive Computing for Text Analysis CS395T / INF385T / LIN386M
University of Texas at Austin, Fall 2011
Lecture 2 September 1, 2011
Jason Baldridge and Matt Lease
https://sites.google.com/a/utcompling.com/dicta-f11/
The paper examines the problem of systems redesign within the context of passive electrical networks and through analogies provides also the means of addressing issues of re-design of mechanical networks. The problem addressed here are special cases of the more general network redesign problem. Redesigning autonomous passive electric networks involves changing the network natural dynamics by modification of the types of elements, possibly their values, interconnection topology and possibly addition, or elimination of parts of the network. We investigate the modelling of systems, whose structure is not fixed but evolves during the system lifecycle. As such, this is a problem that differs considerably from a standard control problem, since it involves changing the system itself without control and aims to achieve the desirable system properties, as these may be expressed by the natural frequencies by system re-engineering. In fact, this problem involves the selection of alternative values for dynamic elements and non-dynamic elements within a fixed interconnection topology and/or alteration of the network interconnection topology and possible evolution of the cardinality of physical elements (increase of elements, branches). The aim of the paper is to define an appropriate representation framework that allows the deployment of control theoretic tools for the re-engineering of properties of a given network. We use impedance and admittance modelling for passive electrical networks and develop a systems framework that is capable of addressing “life-cycle design issues” of networks where the problems of alteration of existing topology and values of the elements, as well as issues of growth, or death of parts of the network are addressed.
We use the Natural Impedance/ Admittance (NI-A) models and we establish a representation of the different types of transformations on such models. This representation provides the means for an appropriate formulation of natural frequencies assignment using the Determinantal Assignment Problem framework defined on appropriate structured transformations. The developed natural representation of transformations are expressed as additive structured transformations. For the simpler case of RL or RC networks it is shown that the single parameter variation problem (dynamic or non-dynamic) is equivalent to Root Locus problems.
follow IEEE NTUA SB on facebook:
https://www.facebook.com/IeeeNtuaSB
Christoph Koch is a professor of Computer Science at EPFL, specializing in data management. Until 2010, he was an Associate Professor in the Department of Computer Science at Cornell University. Previously to this, from 2005 to 2007, he was an Associate Professor of Computer Science at Saarland University. Earlier, he obtained his PhD in Artificial Intelligence from TU Vienna and CERN (2001), was a postdoctoral researcher at TU Vienna and the University of Edinburgh (2001-2003), and an assistant professor at TU Vienna (2003-2005). He has won Best Paper Awards at PODS 2002, ICALP 2005, and SIGMOD 2011, an Outrageous Ideas and Vision Paper Award at CIDR 2013, a Google Research Award (in 2009), and an ERC Grant (in 2011). He is a PI of the FET Flagship Human Brain Project and of NCCR MARVEL, a new Swiss national research center for materials research. He (co-)chaired the program committees of DBPL 2005, WebDB 2008, ICDE 2011, VLDB 2013, and was PC vice-chair of ICDE 2008 and ICDE 2009. He has served on the editorial board of ACM Transactions on Internet Technology and as Editor-in-Chief of PVLDB.
IJERA (International journal of Engineering Research and Applications) is International online, ... peer reviewed journal. For more detail or submit your article, please visit www.ijera.com
Spatially resolved pair correlation functions for point cloud dataTony Fast
Presentation on computing spatial correlation functions for point cloud materials science information. This presentation uses tree algorithms and Fourier methods to compute the statistics. The analysis is performed on Al-Cu interface information provided by John Gibbs and Peter Voorhees at Northwestern University as funded by the Mosaic of Microstructure MURI program.
Similar to Graphs in the Database: Rdbms In The Social Networks Age (20)
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
Neuro-symbolic is not enough, we need neuro-*semantic*Frank van Harmelen
Neuro-symbolic (NeSy) AI is on the rise. However, simply machine learning on just any symbolic structure is not sufficient to really harvest the gains of NeSy. These will only be gained when the symbolic structures have an actual semantics. I give an operational definition of semantics as “predictable inference”.
All of this illustrated with link prediction over knowledge graphs, but the argument is general.
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
Here is something new! In our next Connector Corner webinar, we will demonstrate how you can use a single workflow to:
Create a campaign using Mailchimp with merge tags/fields
Send an interactive Slack channel message (using buttons)
Have the message received by managers and peers along with a test email for review
But there’s more:
In a second workflow supporting the same use case, you’ll see:
Your campaign sent to target colleagues for approval
If the “Approve” button is clicked, a Jira/Zendesk ticket is created for the marketing design team
But—if the “Reject” button is pushed, colleagues will be alerted via Slack message
Join us to learn more about this new, human-in-the-loop capability, brought to you by Integration Service connectors.
And...
Speakers:
Akshay Agnihotri, Product Manager
Charlie Greenberg, Host
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
6. Foreword
S ( b, c) AS first_not_null
chyA
COALESCE(a,
ie IS NOT NULL r ar
h
UN E col2
WHERE O
R SV N
IBOU VER (PART
U b D ITION
R EC D ED BY de
nt
N PR ptno)
TH SELECT * FROM table
weighT)(*) AS c
2
)
http://www.alberton.info/talks
I A age EC
Nt
(
a SUM ED
W HA INN ER L ING
E N JOIN
L
JOI
VIWE t2 Nt
NGX A
COU
T E
TER
A EPT
C
BE LEFTVG t2 ON t1.id = t2.id
JOIN N
MIN(
(sal
Oary) EPT
OU
I
N EXC 50 >
HT
U 00
RIG
3
10. Recommendation Systems
Customers who bought this item also bought
Music Recommended by Last.fm
6
11. Recommendation Systems
Customers who bought this item also bought
Music Recommended by Last.fm
items linked by
similar patterns in
users’ behaviour
6
12. Recommendation Systems
Customers who bought this item also bought
Music Recommended by Last.fm
6
13. Recommendation Systems
items linked by
Customers who bought this item also bought
similar features
(e.g. genre)
Music Recommended by Last.fm
6
33. Graph Representation in the DB
Adjacency Matrix
Nodes N1 N2 N3
N1
N2
N3
...
Requires DDL statements
ALTER TABLE nodes ADD n4 (...)
16
34. Graph Representation in the DB
Adjacency Matrix
Nodes N1 N2 N3
N1
N2
N3
...
Requires DDL statements
ALTER TABLE nodes ADD n4 (...)
16
35. Graph Representation in the DB
Adjacency Matrix Adjacency List
Nodes N1 N2 N3 src dest
N1
N2
N3
...
Requires DDL statements Only DML statements
ALTER TABLE nodes ADD n4 (...) INSERT, DELETE, UPDATE
16
36. Nodes and Edges
nodes
CREATE TABLE nodes (
id INTEGER PRIMARY KEY,
node name age
name VARCHAR(10) NOT NULL,
feat1 CHAR(1), -- e.g., age
feat2 CHAR(1) -- school or company
);
edges
CREATE TABLE edges (
a INTEGER NOT NULL REFERENCES nodes(id) a b
ON UPDATE CASCADE ON DELETE CASCADE,
b INTEGER NOT NULL REFERENCES nodes(id)
ON UPDATE CASCADE ON DELETE CASCADE,
PRIMARY KEY (a, b)
);
CREATE INDEX a_idx ON edges (a);
CREATE INDEX b_idx ON edges (b);
17
37. Nodes and Edges
-- Undirected Graphs: constraint on the uniqueness of the pair
CREATE UNIQUE INDEX pair_unique_idx a b
ON edges (LEAST(a,b), GREATEST(a,b));
3 5
5 3
3 5
-- No self-loops (node linking to itself)
ALTER TABLE edges ADD CONSTRAINT
no_self_loops_chk CHECK (a <> b);
18
38. Nodes and Edges
-- Undirected Graphs: constraint on the uniqueness of the pair
CREATE UNIQUE INDEX pair_unique_idx a b
ON edges (LEAST(a,b), GREATEST(a,b));
3 5
5 3
3 5
x
x
-- No self-loops (node linking to itself)
ALTER TABLE edges ADD CONSTRAINT
no_self_loops_chk CHECK (a <> b);
18
39. Sample Graph
x x
w w
2 3
x z
y w
1 4
x
y
7 5
x
6 y
x
z
19
40. Sample Graph
nodes edges
node name feat1 feat2 a b
1 3
1 node1 x y
2 1
2 node2 x w 2 4
3 node3 x w 3 4
3 5
4 node4 z w 3 6
5 node5 x y 4 7
5 1
6 node6 x z
5 6
7 node7 x y 6 1
20
41. Traversing the Graph
Select nodes connected to node 1
a b
-- Directed Graphs 1 3
2 1
SELECT *
FROM nodes n 3 6
LEFT JOIN edges e ON n.id = e.b
WHERE e.a = 1;
4 7
5 1
5 6
21
42. Traversing the Graph
Select nodes connected to node 1
a b
-- Directed Graphs 1 3
2 1
SELECT *
FROM nodes n 3 6
LEFT JOIN edges e ON n.id = e.b
WHERE e.a = 1;
4 7
5 1
5 6
21
43. Traversing the Graph
Select nodes connected to node 1
a b
-- Directed Graphs 1 3
2 1
SELECT *
FROM nodes n 3 6
LEFT JOIN edges e ON n.id = e.b
WHERE e.a = 1;
4 7
5 1
-- Undirected Graphs
5 6
SELECT * FROM nodes WHERE id IN (
SELECT CASE WHEN a = 1 THEN b ELSE a END
FROM edges
WHERE 1 IN (a, b)
);
21
44. Traversing the Graph
Select nodes connected to node 1
a b
-- Directed Graphs 1 3
2 1
SELECT *
FROM nodes n 3 6
LEFT JOIN edges e ON n.id = e.b
WHERE e.a = 1;
4 7
5 1
-- Undirected Graphs
5 6
SELECT * FROM nodes WHERE id IN (
SELECT CASE WHEN a = 1 THEN b ELSE a END
FROM edges
WHERE 1 IN (a, b)
);
21
45. Traversing the Entire Graph
$nodes = select_friends($me);
foreach ($nodes as $node) {
$nodes2 = select_friends($node);
foreach ($nodes2 as $node) {
...
...
...
}
}
22
47. Traversing the Full Graph
CREATE TEMPORARY TABLE reached (
id INT PRIMARY KEY
);
INSERT INTO reached VALUES (@root_id);
WHILE(@@rowcount > 0)
BEGIN
INSERT INTO reached (id)
SELECT DISTINCT child_id
FROM edges e
JOIN reached p
ON p.id = e.parent_id
WHERE e.child_id NOT IN (
SELECT id FROM reached
)
END;
23
48. Traversing the Full Graph
CREATE TEMPORARY TABLE reached (
id INT PRIMARY KEY
);
INSERT INTO reached VALUES (@root_id);
WHILE(@@rowcount > 0)
BEGIN
INSERT INTO reached (id)
Temporary
SELECT DISTINCT child_id Table
FROM edges e +
JOIN reached p Stored
ON p.id = e.parent_id
WHERE e.child_id NOT IN ( Procedure
SELECT id FROM reached
)
END;
23
49. Common Table Expressions (CTE)
-- VIEW
CREATE VIEW undirected_graph (a, b) AS (
SELECT a, b FROM edges
UNION ALL
SELECT b, a FROM edges
);
SELECT a, b FROM undirected_graph;
24
50. Common Table Expressions (CTE)
-- VIEW
CREATE VIEW undirected_graph (a, b) AS (
SELECT a, b FROM edges
UNION ALL
SELECT b, a FROM edges
);
SELECT a, b FROM undirected_graph;
-- CTE (dynamic VIEW)
WITH undirected_graph (a, b) AS (
SELECT a, b FROM edges
UNION ALL
SELECT b, a FROM edges
)
SELECT a, b FROM undirected_graph;
24
51. Recursive CTEs - Sequence
WITH RECURSIVE seq (n) AS (
-- non recursive term
SELECT 1 AS n
UNION ALL
-- recursive term
SELECT n + 1
FROM seq
WHERE n < 100
)
SELECT n FROM seq;
25
52. Recursive CTEs - Sequence
WITH RECURSIVE seq (n) AS (
-- non recursive term
SELECT 1 AS n
UNION ALL
-- recursive term
SELECT n + 1
FROM seq
WHERE n < 100
)
SELECT n FROM seq;
25
53. Recursive CTEs - Sequence
WITH RECURSIVE seq (n) AS (
-- non recursive term
SELECT 1 AS n
UNION ALL
-- recursive term
SELECT n + 1
FROM seq
WHERE n < 100
)
SELECT n FROM seq;
25
54. Recursive CTEs - Sequence
WITH RECURSIVE seq (n) AS (
-- non recursive term
SELECT 1 AS n
UNION ALL
-- recursive term
SELECT n + 1
FROM seq
WHERE n < 100
)
SELECT n FROM seq;
25
55. Recursive CTEs - Sequence
WITH RECURSIVE seq (n) AS (
n
-- non recursive term 1
SELECT 1 AS n
2
UNION ALL 3
4
-- recursive term
SELECT n + 1 5
FROM seq
...
WHERE n < 100
100
)
SELECT n FROM seq;
25
56. Recursive CTEs - Fibonacci Seq.
WITH RECURSIVE fib (i, j) AS (
-- non recursive term
SELECT 0, 1
UNION ALL
-- recursive term
SELECT GREATEST(i, j),
(i + j) AS i
FROM fib
WHERE j < 1000
)
SELECT i FROM fib;
26
57. Recursive CTEs - Fibonacci Seq.
WITH RECURSIVE fib (i, j) AS (
-- non recursive term
SELECT 0, 1
UNION ALL
-- recursive term
SELECT GREATEST(i, j),
(i + j) AS i
FROM fib
WHERE j < 1000
)
SELECT i FROM fib;
26
58. Recursive CTEs - Fibonacci Seq.
WITH RECURSIVE fib (i, j) AS (
-- non recursive term
SELECT 0, 1
UNION ALL
-- recursive term
SELECT GREATEST(i, j),
(i + j) AS i
FROM fib
WHERE j < 1000
)
SELECT i FROM fib;
26
59. Recursive CTEs - Fibonacci Seq.
WITH RECURSIVE fib (i, j) AS (
i
-- non recursive term 0
SELECT 0, 1 1
1
UNION ALL
2
-- recursive term 5
SELECT GREATEST(i, j),
8
(i + j) AS i
FROM fib 13
WHERE j < 1000 21
)
...
SELECT i FROM fib;
26
60. Recursive CTEs
CREATE TABLE orgchart (
emp VARCHAR(10) PRIMARY KEY,
boss VARCHAR(10) REFERENCES orgchart(emp),
salary DECIMAL(10,2)
);
INSERT INTO orgchart
(emp, boss, salary) VALUES
(‘A’, NULL, 1000.00),
(‘B’, ‘A’, 900.00),
(‘C’, ‘A’, 900.00),
(‘D’, ‘C’, 800.00), A
(‘E’, ‘C’, 700.00),
(‘F’, ‘C’, 600.00),
(‘G’, ‘B’, 800.00); B C
G D E F
27
61. Recursive CTEs
CREATE TABLE orgchart (
emp VARCHAR(10) PRIMARY KEY,
boss VARCHAR(10) REFERENCES orgchart(emp),
salary DECIMAL(10,2)
emp boss salary
);
A NULL 1000.00
INSERT INTO orgchart B A 900.00
(emp, boss, salary) VALUES C A 900.00
(‘A’, NULL, 1000.00), D C 800.00
(‘B’, ‘A’, 900.00), E C 700.00
(‘C’, ‘A’, 900.00), F C 600.00
(‘D’, ‘C’, 800.00), A G B 800.00
(‘E’, ‘C’, 700.00),
(‘F’, ‘C’, 600.00),
(‘G’, ‘B’, 800.00); B C
G D E F
27
62. Recursive CTEs
WITH RECURSIVE hierarchy AS (
-- non recursive term
SELECT *
FROM orgchart
WHERE boss IS NULL
UNION ALL
-- recursive term
SELECT E1.*
FROM orgchart AS E1
JOIN hierarchy AS E2
ON E1.boss = E2.emp
)
SELECT *
FROM hierarchy
ORDER BY emp;
28
63. Recursive CTEs
WITH RECURSIVE hierarchy AS (
-- non recursive term
SELECT *
FROM orgchart
WHERE boss IS NULL
UNION ALL
-- recursive term
SELECT E1.*
FROM orgchart AS E1
JOIN hierarchy AS E2
ON E1.boss = E2.emp
)
SELECT *
FROM hierarchy
ORDER BY emp;
28
64. Recursive CTEs
WITH RECURSIVE hierarchy AS (
-- non recursive term
SELECT *
FROM orgchart
WHERE boss IS NULL
UNION ALL
-- recursive term
SELECT E1.*
FROM orgchart AS E1
JOIN hierarchy AS E2
ON E1.boss = E2.emp
)
SELECT *
FROM hierarchy
ORDER BY emp;
28
65. Recursive CTEs
WITH RECURSIVE hierarchy AS (
-- non recursive term
SELECT *
FROM orgchart
WHERE boss IS NULL
UNION ALL
-- recursive term
SELECT E1.*
FROM orgchart AS E1
JOIN hierarchy AS E2
ON E1.boss = E2.emp
)
SELECT *
FROM hierarchy
ORDER BY emp;
28
66. Recursive CTEs
WITH RECURSIVE hierarchy AS (
-- non recursive term
SELECT *
FROM orgchart emp boss salary
WHERE boss IS NULL A NULL 1000.00
UNION ALL B A 900.00
-- recursive term C A 900.00
SELECT E1.*
FROM orgchart AS E1 D C 800.00
JOIN hierarchy AS E2 E C 700.00
ON E1.boss = E2.emp F C 600.00
) G B 800.00
SELECT *
FROM hierarchy
ORDER BY emp;
28
67. Recursive CTEs
WITH RECURSIVE hierarchy AS (
SELECT *,
1 AS lvl,
CAST(emp AS TEXT) AS tree,
emp || ‘.’ AS path
FROM orgchart
WHERE boss IS NULL
UNION ALL
SELECT E1.*,
E2.lvl + 1 AS lvl,
LPAD(E1.emp, lvl * 2, ‘ ’) AS tree,
E2.path || E1.emp || ‘.’ AS path
FROM orgchart
JOIN hierarchy AS E2
ON E1.boss = E2.emp
)
SELECT *
FROM hierarchy
ORDER BY path;
29
68. Recursive CTEs
WITH RECURSIVE hierarchy AS (
SELECT *,
1 AS lvl,
CAST(emp AS TEXT) AS tree,
emp || ‘.’ AS path
FROM orgchart
WHERE boss IS NULL
UNION ALL
SELECT E1.*,
E2.lvl + 1 AS lvl,
LPAD(E1.emp, lvl * 2, ‘ ’) AS tree,
E2.path || E1.emp || ‘.’ AS path
FROM orgchart
JOIN hierarchy AS E2
ON E1.boss = E2.emp
)
SELECT *
FROM hierarchy
ORDER BY path;
29
69. Recursive CTEs
WITH RECURSIVE hierarchy AS (
SELECT *,
1 AS lvl,
CAST(emp AS TEXT) AS tree,
emp || ‘.’ AS path
FROM orgchart
WHERE boss IS NULL
UNION ALL
SELECT E1.*,
E2.lvl + 1 AS lvl,
LPAD(E1.emp, lvl * 2, ‘ ’) AS tree,
E2.path || E1.emp || ‘.’ AS path
FROM orgchart
JOIN hierarchy AS E2
ON E1.boss = E2.emp
)
SELECT *
FROM hierarchy
ORDER BY path;
29
70. Recursive CTEs
WITH RECURSIVE hierarchy AS (
SELECT *,
1 AS lvl,
CAST(emp AS TEXT) AS tree,
emp || ‘.’ AS path
FROM orgchart
WHERE boss IS NULL
UNION ALL
SELECT E1.*,
E2.lvl + 1 AS lvl,
LPAD(E1.emp, lvl * 2, ‘ ’) AS tree,
E2.path || E1.emp || ‘.’ AS path
FROM orgchart
JOIN hierarchy AS E2
ON E1.boss = E2.emp
)
SELECT *
FROM hierarchy
ORDER BY path;
29
71. Recursive CTEs
WITH RECURSIVE hierarchy AS (
SELECT *,
1 AS lvl,
CAST(emp AS TEXT) AS tree,
emp || ‘.’ AS path
FROM orgchart
WHERE boss IS NULL
UNION ALL
SELECT E1.*,
E2.lvl + 1 AS lvl,
LPAD(E1.emp, lvl * 2, ‘ ’) AS tree,
E2.path || E1.emp || ‘.’ AS path
FROM orgchart
JOIN hierarchy AS E2
ON E1.boss = E2.emp
)
SELECT *
FROM hierarchy
ORDER BY path;
29
72. Recursive CTEs
WITH RECURSIVE hierarchy AS (
SELECT *,
emp boss lvl,salary
1 AS lvl tree path
CAST(emp AS TEXT) AS tree,
A NULL|| ‘.’ AS path 1
emp 1000.00 A A.
FROM orgchart
B A 900.00
WHERE boss IS NULL 2 B A.B.
UNION ALL
G B
SELECT E1.*, 800.00 3 G A.B.G.
E2.lvl + 1 AS lvl,
C LPAD(E1.emp, lvl * 2, ‘ ’) AS tree,
A 900.00 2 C A.C.
E2.path || E1.emp || ‘.’ AS path
D FROM orgchart 800.00
C 3 D A.C.D.
JOIN hierarchy AS E2
E ON E1.boss =700.00
C E2.emp 3 E A.C.E.
)
SELECT *
F C 600.00 3 F A.C.F.
FROM hierarchy
ORDER BY path;
29
73. Recursive CTEs
WITH RECURSIVE hierarchy AS (
SELECT *,
1 AS lvl,
CAST(emp AS TEXT) AS tree
FROM orgchart
WHERE boss = ‘A’
UNION ALL
SELECT E1.*,
E2.lvl + 1 AS lvl,
LPAD(E1.emp, depth * 2, ‘ ’) AS tree
FROM orgchart
JOIN hierarchy AS E2 ON E1.boss = E2.emp
WHERE E2.lvl < 3 -- termination condition
)
SELECT *
FROM hierarchy
ORDER BY path;
30
78. Transitive Closure with CTEs
WITH RECURSIVE transitive_closure (a, b, distance,
path_string) AS
( SELECT a, b, 1 AS distance,
'.' || a || '.' || b || '.' AS path_string
FROM edges
UNION ALL
SELECT tc.a, e.b, tc.distance + 1,
tc.path_string || e.b || '.' AS path_string
FROM edges AS e
JOIN transitive_closure AS tc
ON e.a = tc.b
WHERE tc.path_string NOT LIKE '%.' || e.b || '.%'
)
SELECT * FROM transitive_closure
ORDER BY a, b, distance;
32
79. Transitive Closure with CTEs
WITH RECURSIVE transitive_closure (a, b, distance,
path_string) AS
( SELECT a, b, 1 AS distance,
'.' || a || '.' || b || '.' AS path_string
FROM edges
UNION ALL
SELECT tc.a, e.b, tc.distance + 1,
tc.path_string || e.b || '.' AS path_string
FROM edges AS e
JOIN transitive_closure AS tc
ON e.a = tc.b
WHERE tc.path_string NOT LIKE '%.' || e.b || '.%'
)
SELECT * FROM transitive_closure
ORDER BY a, b, distance;
32
80. Transitive Closure with CTEs
WITH RECURSIVE transitive_closure (a, b, distance,
path_string) AS
( SELECT a, b, 1 AS distance,
'.' || a || '.' || b || '.' AS path_string
FROM edges
UNION ALL
SELECT tc.a, e.b, tc.distance + 1,
tc.path_string || e.b || '.' AS path_string
FROM edges AS e
JOIN transitive_closure AS tc
ON e.a = tc.b
WHERE tc.path_string NOT LIKE '%.' || e.b || '.%'
)
SELECT * FROM transitive_closure
ORDER BY a, b, distance;
32
81. Transitive Closure with CTEs
WITH RECURSIVE transitive_closure (a, b, distance,
path_string) AS
( SELECT a, b, 1 AS distance,
'.' || a || '.' || b || '.' AS path_string
FROM edges
UNION ALL
SELECT tc.a, e.b, tc.distance + 1,
tc.path_string || e.b || '.' AS path_string
FROM edges AS e
JOIN transitive_closure AS tc
ON e.a = tc.b
WHERE tc.path_string NOT LIKE '%.' || e.b || '.%'
)
SELECT * FROM transitive_closure
ORDER BY a, b, distance;
32
82. Transitive Closure with CTEs
WITH RECURSIVE transitive_closure (a, b, distance,
path_string) AS
( SELECT a, b, 1 AS distance,
'.' || a || '.' || b || '.' AS path_string
FROM edges
UNION ALL
SELECT tc.a, e.b, tc.distance + 1,
tc.path_string || e.b || '.' AS path_string
FROM edges AS e
JOIN transitive_closure AS tc
ON e.a = tc.b
WHERE tc.path_string NOT LIKE '%.' || e.b || '.%'
)
SELECT * FROM transitive_closure
ORDER BY a, b, distance;
32
83. Transitive Closure with CTEs
WITH RECURSIVE transitive_closure (a, b, distance,
path_string) AS
( SELECT a, b, 1 AS distance,
'.' || a || '.' || b || '.' AS path_string
FROM edges
UNION ALL
SELECT tc.a, e.b, tc.distance + 1,
tc.path_string || e.b || '.' AS path_string
FROM edges AS e
JOIN transitive_closure AS tc
ON e.a = tc.b
WHERE tc.path_string NOT LIKE '%.' || e.b || '.%'
)
SELECT * FROM transitive_closure
ORDER BY a, b, distance;
32
84. Transitive Closure with CTEs
WITH RECURSIVE transitive_closure (a, b, distance,
path_string) AS
( SELECT a, b, 1 AS distance,
'.' || a || '.' || b || '.' AS path_string
FROM edges
UNION ALL
SELECT tc.a, e.b, tc.distance + 1,
tc.path_string || e.b || '.' AS path_string
FROM edges AS e
JOIN transitive_closure AS tc
ON e.a = tc.b
WHERE tc.path_string NOT LIKE '%.' || e.b || '.%'
)
SELECT * FROM transitive_closure
ORDER BY a, b, distance;
32
85. Transitive Closure with CTEs
WITHa RECURSIVE transitive_closure (a, path_string
b distance b, distance,
path_string) AS
1 3 1
( SELECT a, b, 1 AS distance, .1.3.
'.' || a || '.' || b || '.' AS path_string
FROM edges 4
1 2 .1.3.4.
UNION ALL 5
1 2 .1.3.5.
1 6 2 .1.3.6.
SELECT tc.a, e.b, tc.distance + 1,
tc.path_string || e.b || '.' AS path_string
1 6
FROM edges AS e 3 .1.3.5.6.
JOIN transitive_closure AS tc
1 ON e.a = tc.b
7 3 .1.3.4.7.
WHERE tc.path_string NOT LIKE '%.' || e.b || '.%'
) 2 1 1 .2.1.
SELECT * FROM transitive_closure
... BY a, b, distance; ...
ORDER ... ...
32
88. Travel Planning: Possible Routes
WITH RECURSIVE transitive_closure (a, b, distance,
path_string) AS
( SELECT a, b, 1 AS distance,
'.' || a || '.' || b || '.' AS path_string
FROM edges
WHERE a = 1 -- source
UNION ALL
SELECT tc.a, e.b, tc.distance + 1,
tc.path_string || e.b || '.' AS path_string
FROM edges AS e
JOIN transitive_closure AS tc ON e.a = tc.b
WHERE tc.path_string NOT LIKE '%.' || e.b || '.%'
)
SELECT * FROM transitive_closure
WHERE b = 6 -- destination
ORDER BY a, b, distance;
34
89. Travel Planning: Possible Routes
WITH RECURSIVE transitive_closure (a, b, distance,
path_string) AS
( SELECT a, b, 1 AS distance,
'.' || a || '.' || b || '.' AS path_string
FROM edges
WHERE a = 1 -- source
UNION ALL
SELECT tc.a, e.b, tc.distance + 1,
tc.path_string || e.b || '.' AS path_string
FROM edges AS e
JOIN transitive_closure AS tc ON e.a = tc.b
WHERE tc.path_string NOT LIKE '%.' || e.b || '.%'
)
SELECT * FROM transitive_closure
WHERE b = 6 -- destination
ORDER BY a, b, distance;
34
90. Travel Planning: Possible Routes
WITH RECURSIVE transitive_closure (a, b, distance,
path_string) AS
( SELECT a, b, 1 AS distance,
'.' || a || '.' || b || '.' AS path_string
FROM edges
WHERE a = 1 -- source
a
UNION ALL b distance path_string
SELECT tc.a, e.b, tc.distance + 1,
1 tc.path_string ||2e.b || '.' AS path_string
6 .1.3.6.
FROM edges AS e
JOIN transitive_closure 3 tc ON e.a = tc.b
1 6 AS .1.3.5.6.
WHERE tc.path_string NOT LIKE '%.' || e.b || '.%'
)
SELECT * FROM transitive_closure
WHERE b = 6 -- destination
ORDER BY a, b, distance;
34
93. LinkedIN: Degrees of Separation
WITH RECURSIVE transitive_closure (a, b, distance,
path_string)
AS
( SELECT a, b, 1 AS distance,
'.' || a || '.' || b || '.' AS path_string
FROM edges2
WHERE a = 1
UNION ALL
SELECT tc.a, e.b, tc.distance + 1,
tc.path_string || e.b || '.' AS path_string
FROM edges2 AS e
JOIN transitive_closure AS tc ON e.a = tc.b
WHERE tc.path_string NOT LIKE '%.' || e.b || '.%'
)
SELECT a, b, MIN(distance) AS dist FROM transitive_closure
--WHERE b = 6 (or where name matches pattern)
GROUP BY a, b ORDER BY a, dist, b;
36
94. LinkedIN: Degrees of Separation
WITH RECURSIVE transitive_closure (a, b, distance,
path_string)
AS
( SELECT a, b, 1 AS distance,
'.' || a || '.' || b || '.' AS path_string
FROM edges2
WHERE a = 1
UNION ALL
SELECT tc.a, e.b, tc.distance + 1,
tc.path_string || e.b || '.' AS path_string
FROM edges2 AS e
JOIN transitive_closure AS tc ON e.a = tc.b
WHERE tc.path_string NOT LIKE '%.' || e.b || '.%'
)
SELECT a, b, MIN(distance) AS dist FROM transitive_closure
--WHERE b = 6 (or where name matches pattern)
GROUP BY a, b ORDER BY a, dist, b;
36
95. LinkedIN: Degrees of Separation
WITH RECURSIVE transitive_closure (a, b, distance,
path_string)
AS
( SELECT a, b, 1 AS distance,
'.' || a || '.' || b || '.' AS path_string
FROM edges2
WHERE a = 1
UNION ALL
SELECT tc.a, e.b, tc.distance + 1,
tc.path_string || e.b || '.' AS path_string
FROM edges2 AS e
JOIN transitive_closure AS tc ON e.a = tc.b
WHERE tc.path_string NOT LIKE '%.' || e.b || '.%'
)
SELECT a, b, MIN(distance) AS dist FROM transitive_closure
--WHERE b = 6 (or where name matches pattern)
GROUP BY a, b ORDER BY a, dist, b;
36
96. LinkedIN: Degrees of Separation
WITH RECURSIVE transitive_closure (a, b, distance,
path_string)
AS
a b
( SELECT a, b, 1 AS distance, dist
'.' || a || '.' || b || '.' AS path_string
1
FROM edges2 2 1
WHERE a = 1
UNION 1ALL 3 1
SELECT1 tc.a, e.b, tc.distance + 1,
5 1
tc.path_string || e.b || '.' AS path_string
1
FROM edges2 AS e 6 1
JOIN transitive_closure AS tc ON e.a = tc.b
WHERE tc.path_string NOT 4
1 2
LIKE '%.' || e.b || '.%'
)
... ... ...
SELECT a, b, MIN(distance) AS dist FROM transitive_closure
--WHERE b = 6 (or where name matches pattern)
GROUP BY a, b ORDER BY a, dist, b;
36
99. LinkedIN: Shared Nodes (1)
SELECT b FROM (
[SELECT b FROM transitive_closure]
WHERE a = 1 -- set the starting node (node1)
...
WHERE distance = 0 -- limit the recursion to the first step
UNION ALL
[SELECT b FROM transitive_closure]
WHERE a = 4 -- set the other starting node (node4)
...
WHERE distance = 0 -- limit the recursion to the first step
)
AS immediate_connections
GROUP BY b
HAVING COUNT(b) > 1;
38
100. LinkedIN: Shared Nodes (1)
SELECT b FROM (
[SELECT b FROM transitive_closure]
WHERE a = 1 -- set the starting node (node1)
...
WHERE distance = 0 -- limit the recursion to the first step
UNION ALL
[SELECT b FROM transitive_closure]
WHERE a = 4 -- set the other starting node (node4)
...
WHERE distance = 0 -- limit the recursion to the first step
)
AS immediate_connections
GROUP BY b
HAVING COUNT(b) > 1;
38
101. LinkedIN: Shared Nodes (2)
SELECT b FROM (
SELECT b
FROM edges2
WHERE a = 1 -- set the starting node (node1)
UNION ALL
SELECT b
FROM edges2
WHERE a = 4 -- set the other starting node (node4)
) AS immediate_connections
GROUP BY b
HAVING COUNT(b) > 1;
39
102. LinkedIN: Shared Nodes (3)
SELECT e.b
FROM edges2 AS e
WHERE e.a = 1 -- node1
AND EXISTS (
SELECT *
FROM edges2 AS e2
WHERE e2.a = 4 -- node4
AND e2.b = e.b
)
40
103. LinkedIN: Shared Nodes (3)
SELECT e.b
FROM edges2 AS e
WHERE e.a = 1 -- node1
AND EXISTS (
SELECT *
FROM edges2 AS e2
WHERE e2.a = 4 -- node4
AND e2.b = e.b
)
40
106. LinkedIN: Shared Nodes (4)
SELECT b FROM edges2 WHERE a = 1
INTERSECT
SELECT b FROM edges2 WHERE a = 4
A’s B’s
connections connections
shared
connections
41
111. LinkedIN: How is connected to you
WITH RECURSIVE tc (a, b, distance, path_string) AS
( SELECT a, b, 1 AS distance,
'.' || a || '.' || b || '.' AS path_string
FROM edges2
WHERE a = 8 -- set the target node
UNION ALL
SELECT tc.a, e.b, tc.distance + 1,
tc.path_string || e.b || '.' AS path_string
FROM edges2 AS e
JOIN tc ON e.a = tc.b
WHERE tc.path_string NOT LIKE '%.' || e.b || '.%'
AND e.b <> 1
AND tc.distance < 5
)
SELECT b AS immediate_connection, MIN(distance) + 1 AS
distance_via_node FROM tc
WHERE EXISTS (SELECT * FROM edges2 WHERE a = 1 AND b = tc.b)
GROUP BY b
HAVING MIN(distance) > 1
ORDER BY b
44
112. LinkedIN: How is connected to you
WITH RECURSIVE tc (a, b, distance, path_string) AS
( SELECT a, b, 1 AS distance,
'.' || a || '.' || b || '.' AS path_string
FROM edges2
WHERE a = 8 -- set the target node
UNION ALL
SELECT tc.a, e.b, tc.distance + 1,
tc.path_string || e.b || '.' AS path_string
FROM edges2 AS e
JOIN tc ON e.a = tc.b
WHERE tc.path_string NOT LIKE '%.' || e.b || '.%'
AND e.b <> 1
AND tc.distance < 5
)
SELECT b AS immediate_connection, MIN(distance) + 1 AS
distance_via_node FROM tc
WHERE EXISTS (SELECT * FROM edges2 WHERE a = 1 AND b = tc.b)
GROUP BY b
HAVING MIN(distance) > 1
ORDER BY b
44
113. LinkedIN: How is connected to you
WITH RECURSIVE tc (a, b, distance, path_string) AS
( SELECT a, b, 1 AS distance,
'.' || a || '.' || b || '.' AS path_string
FROM edges2
WHERE a = 8 -- set the target node
UNION ALL
SELECT tc.a, e.b, tc.distance + 1,
tc.path_string || e.b || '.' AS path_string
FROM edges2 AS e
JOIN tc ON e.a = tc.b
WHERE tc.path_string NOT LIKE '%.' || e.b || '.%'
AND e.b <> 1 you
AND tc.distance < 5
)
SELECT b AS immediate_connection, MIN(distance) + 1 AS
distance_via_node FROM tc
WHERE EXISTS (SELECT * FROM edges2 WHERE a = 1 AND b = tc.b)
GROUP BY b
HAVING MIN(distance) > 1
ORDER BY b
44
114. LinkedIN: How is connected to you
WITH RECURSIVE tc (a, b, distance, path_string) AS
( SELECT a, b, 1 AS distance,
'.' || a || '.' || b || '.' AS path_string
FROM edges2
WHERE a = 8 -- set the target node
UNION ALL
SELECT tc.a, e.b, tc.distance + 1,
tc.path_string || e.b || '.' AS path_string
FROM edges2 AS e
JOIN tc ON e.a = tc.b
WHERE tc.path_string NOT LIKE '%.' || e.b || '.%'
AND e.b <> 1
AND tc.distance < 5
)
SELECT b AS immediate_connection, MIN(distance) + 1 AS
distance_via_node FROM tc
WHERE EXISTS (SELECT * FROM edges2 WHERE a = 1 AND b = tc.b)
GROUP BY b
HAVING MIN(distance) > 1
ORDER BY b
44
115. LinkedIN: How is connected to you
WITH RECURSIVE tc (a, b, distance, path_string) AS
( SELECT a, b, 1 AS distance,
'.' || a || '.' || b || '.' AS path_string
FROM edges2
WHERE a = 8 -- set the target node
UNION ALL
SELECT tc.a, e.b, tc.distance + 1,
tc.path_string || e.b || '.' AS path_string
FROM edges2 AS e
JOIN tc ON e.a = tc.b
WHERE tc.path_string NOT LIKE '%.' || e.b || '.%'
AND e.b <> 1
AND tc.distance < 5
)
SELECT b AS immediate_connection, MIN(distance) + 1 AS
distance_via_node FROM tc
WHERE EXISTS (SELECT * FROM edges2 WHERE a = 1 AND b = tc.b)
GROUP BY b
you
HAVING MIN(distance) > 1
ORDER BY b
44
116. LinkedIN: How is connected to you
WITH RECURSIVE tc (a, b, distance, path_string) AS
( SELECT a, b, 1 AS distance,
'.' || a || '.' || b || '.' AS path_string
FROM edges2
WHERE a = 8 -- set the target node
UNION ALL
SELECT tc.a, e.b, tc.distance + 1,
tc.path_string || e.b || '.' AS path_string
FROM edges2 AS e
JOIN tc ON e.a = tc.b
WHERE tc.path_string NOT LIKE '%.' || e.b || '.%'
AND e.b <> 1
AND tc.distance < 5
)
SELECT b AS immediate_connection, MIN(distance) + 1 AS
distance_via_node FROM tc
WHERE EXISTS (SELECT * FROM edges2 WHERE a = 1 AND b = tc.b)
GROUP BY b
HAVING MIN(distance) > 1
ORDER BY b
44
117. LinkedIN: How is connected to you
WITH RECURSIVE tc (a, b, distance, path_string) AS
( SELECT a, b, 1 AS distance,
'.' || a || '.' || b || '.' AS path_string
FROM edges2
WHERE a = 8 -- set the target node
UNION ALL
SELECT tc.a, e.b, tc.distance + 1,
tc.path_string || e.b || '.' AS path_string
FROM edges2 AS e
JOIN tc ON e.a = tc.b
WHERE tc.path_string NOT LIKE '%.' || e.b || '.%'
AND e.b <> 1
AND tc.distance < 5
)
SELECT b AS immediate_connection, MIN(distance) + 1 AS
distance_via_node FROM tc
WHERE EXISTS (SELECT * FROM edges2 WHERE a = 1 AND b = tc.b)
GROUP BY b
HAVING MIN(distance) > 1
ORDER BY b
44
118. LinkedIN: How is connected to you
WITH RECURSIVE tc (a, b, distance, path_string) AS
( SELECT a, b, 1 AS distance,
'.' || a || '.' || b || '.' AS path_string
FROM edges2
immediate_connection distance_via_node
WHERE a = 8 -- set the target node
UNION ALL
2
SELECT tc.a, e.b, tc.distance + 1, 4
tc.path_string || e.b || '.' AS path_string
FROM edges2 AS 3 4
you e
JOIN tc ON e.a = tc.b
n2
5 4
WHERE tc.path_string NOT LIKE '%.' || e.b || '.%'
AND e.b <> 1
)
6
AND tc.distance < 5 3
SELECT b AS immediate_connection, MIN(distance) + 1 AS
distance_via_node FROM tc
WHERE EXISTS (SELECT * FROM edges2 WHERE a = 1 AND b = tc.b)
GROUP BY b
HAVING MIN(distance) > 1
ORDER BY b
44
122. Facebook: You might also know (1)
WITH RECURSIVE transitive_closure (a, b, distance,
path_string) AS
( SELECT a, b, 1 AS distance,
'.' || a || '.' || b || '.' AS path_string
FROM edges2
WHERE a = 1 -- set the starting node
UNION ALL
SELECT tc.a, e.b, tc.distance + 1,
tc.path_string || e.b || '.' AS path_string
FROM edges2 AS e
JOIN transitive_closure AS tc ON e.a = tc.b
WHERE tc.path_string NOT LIKE '%.' || e.b || '.%'
AND tc.distance < 2
)
SELECT a, b
FROM transitive_closure
GROUP BY a, b
HAVING MIN(distance) = 2 -- select nodes 2 steps away
46
123. Facebook: You might also know (1)
WITH RECURSIVE transitive_closure (a, b, distance,
path_string) AS
( SELECT a, b, 1 AS distance,
'.' || a || '.' || b || '.' AS path_string
FROM edges2
WHERE a = 1 -- set the starting node
UNION ALL
SELECT tc.a, e.b, tc.distance + 1,
tc.path_string || e.b || '.' AS path_string
FROM edges2 AS e
JOIN transitive_closure AS tc ON e.a = tc.b
WHERE tc.path_string NOT LIKE '%.' || e.b || '.%'
AND tc.distance < 2
)
SELECT a, b
FROM transitive_closure
GROUP BY a, b
HAVING MIN(distance) = 2 -- select nodes 2 steps away
46
124. Facebook: You might also know (2)
SELECT a AS you,
b AS might_know,
CASE WHEN n1.feat1 = n2.feat1 THEN 'feat1'
WHEN n1.feat2 = n2.feat2 THEN 'feat2'
ELSE 'nothing'
END AS common_feature
FROM (
CTE for nodes 2 steps away (previous slide)
) AS youmightknow
LEFT JOIN nodes AS n1 ON youmightknow.a = n1.id
LEFT JOIN nodes AS n2 ON youmightknow.b = n2.id
WHERE n1.feat1 = n2.feat1
OR n1.feat2 = n2.feat2;
47
125. Facebook: You might also know (2)
SELECT a AS you,
b AS might_know,
CASE WHEN n1.feat1 = n2.feat1 THEN 'feat1'
WHEN n1.feat2 = n2.feat2 THEN 'feat2'
ELSE 'nothing'
END AS common_feature
FROM (
CTE for nodes 2 steps away (previous slide)
) AS youmightknow
LEFT JOIN nodes AS n1 ON youmightknow.a = n1.id
LEFT JOIN nodes AS n2 ON youmightknow.b = n2.id
WHERE n1.feat1 = n2.feat1
OR n1.feat2 = n2.feat2;
47
126. Facebook: You might also know (2)
SELECT a AS you,
b AS might_know,
CASE WHEN n1.feat1 = n2.feat1 THEN 'feat1'
WHEN n1.feat2 = n2.feat2 THEN 'feat2'
ELSE 'nothing'
END AS common_feature
FROM (
you might_know common_feature
1 7 feat1
CTE for nodes 2 steps away (previous slide)
1 13
) AS youmightknow feat2
LEFT JOIN nodes AS n1 ON youmightknow.a = n1.id
LEFT JOIN nodes AS n2 ON youmightknow.b = n2.id
WHERE n1.feat1 = n2.feat1
OR n1.feat2 = n2.feat2;
47
128. Sample Table
company
id emp dept salary
1 Robert Management 2500
2 Jane Sales 1800
3 Dave Sales 1700
4 Clare Development 1900
5 Richard Development 1500
6 Simon Development 1850
7 Elizabeth Tech Support 1350
8 Dylan Tech Support 1450
... ... ... ...
49
129. Aggregates
SELECT dept,
AVG(salary)
FROM company
GROUP BY dept
dept AVG(salary)
Management 2500
Sales 1750
Development 1750
Tech Support 1400
50
130. Window Functions (SQL-2003)
SELECT id, emp, dept, salary,
SUM(salary) OVER (PARTITION BY dept)
FROM company
id emp dept salary SUM(salary)
1 Robert Management 2500 2500
2 Jane Sales 1800 3500
3 Dave Sales 1700 3500
4 Clare Development 1900 5250
5 Richard Development 1500 5250
6 Simon Development 1850 5250
7 Elizabeth Tech Support 1350 2800
8 Dylan Tech Support 1450 2800
51
131. Window Functions (SQL-2003)
SELECT id, emp, dept, salary,
ROUND(salary - AVG(salary) OVER
(PARTITION BY dept), 0) AS diff_avg_dept
FROM company
id emp dept salary diff_avg_dept
1 Robert Management 2500 0
2 Jane Sales 1800 50
3 Dave Sales 1700 -50
4 Clare Development 1900 150
5 Richard Development 1500 -250
6 Simon Development 1850 100
7 Elizabeth Tech Support 1350 -50
8 Dylan Tech Support 1450 50
52
134. Window Functions Syntax
function (args) OVER (
[partition clause]
[order by clause]
[frame clause]
)
PARTITION BY expr, ...
(if empty, over the entire result set)
54
135. Window Functions Syntax
function (args) OVER (
[partition clause]
[order by clause]
[frame clause]
)
ORDER BY expr [ASC|DESC]
[NULLS FIRST|LAST], ...
(useful for order and ranking functions)
54
136. Window Functions Syntax
function (args) OVER (
[partition clause]
[order by clause]
[frame clause]
)
(ROWS|RANGE) [BETWEEN
(UNBOUNDED|expr)
(PRECEDING|FOLLOWING)
AND] CURRENT ROW
54
138. Named Windows and Ranking
SELECT emp, dept, salary, row_number()
OVER w, rank() OVER w, dense_rank() OVER w
FROM company WINDOW w AS (ORDER BY salary DESC)
ORDER BY salary DESC
emp dept salary row_number rank dense_rank
Robert Management 2500 1 1 1
Clare Development 1900 2 2 2
Simon Development 1800 3 3 3
Jane Sales 1800 4 3 3
Dave Sales 1700 5 5 4
Richard Development 1500 6 6 5
Dylan Tech Support 1450 7 7 6
Elizabeth Tech Support 1350 8 8 7
55
139. Named Windows and Ranking
SELECT emp, dept, salary, row_number()
OVER w, rank() OVER w, dense_rank() OVER w
FROM company WINDOW w AS (ORDER BY salary DESC)
ORDER BY salary DESC
emp dept salary row_number rank dense_rank
Robert Management 2500 1 1 1
Clare Development 1900 2 2 2
Simon Development 1800 3 3 3
Jane Sales 1800 4 3 3
Dave Sales 1700 5 5 4
Richard Development 1500 6 6 5
Dylan Tech Support 1450 7 7 6
Elizabeth Tech Support 1350 8 8 7
55
140. Named Windows and Ranking
SELECT emp, dept, salary, row_number()
OVER w, rank() OVER w, dense_rank() OVER w
FROM company WINDOW w AS (ORDER BY salary DESC)
ORDER BY salary DESC
emp dept salary row_number rank dense_rank
Robert Management 2500 1 1 1
Clare Development 1900 2 2 2
Simon Development 1800 3 3 3
Jane Sales 1800 4 3 3
Dave Sales 1700 5 5 4
Richard Development 1500 6 6 5
Dylan Tech Support 1450 7 7 6
Elizabeth Tech Support 1350 8 8 7
55
141. Cumulative Sum
SELECT id,
customer,
article,
price,
SUM(price) OVER (PARTITION BY customer
ORDER BY purchase_date
ROWS BETWEEN UNBOUNDED PRECEDING
AND CURRENT ROW) AS cumulative,
SUM(price) OVER (PARTITION BY customer)
AS tot_price
FROM orders
ORDER BY customer
56
142. Cumulative Sum
SELECT id,
customer,
article,
price,
SUM(price) OVER (PARTITION BY customer
ORDER BY purchase_date
ROWS BETWEEN UNBOUNDED PRECEDING
AND CURRENT ROW) AS cumulative,
SUM(price) OVER (PARTITION BY customer)
AS tot_price
FROM orders
ORDER BY customer
56
146. Multiple Partitions
SELECT id,
customer,
article,
price,
SUM(price) OVER (PARTITION BY customer
ORDER BY purchase_date
ROWS BETWEEN UNBOUNDED PRECEDING
AND CURRENT ROW) AS cumulative,
SUM(price) OVER (PARTITION BY customer)
AS tot_price
SUM(price) OVER (PARTITION BY article)
AS tot_price_by_article
FROM orders
ORDER BY customer
58
147. Multiple Partitions
SELECT id,
customer,
article,
price,
SUM(price) OVER (PARTITION BY customer
ORDER BY purchase_date
ROWS BETWEEN UNBOUNDED PRECEDING
AND CURRENT ROW) AS cumulative,
SUM(price) OVER (PARTITION BY customer)
AS tot_price
SUM(price) OVER (PARTITION BY article)
AS tot_price_by_article
FROM orders
ORDER BY customer
58
149. Address Book
SELECT MIN(firstname) || ' - ' ||
MAX(firstname) AS name_range,
TRUNC(rn / 250) + 1 AS chunk,
COUNT(*) AS chunk_size,
tot
FROM (
SELECT firstname,
row_number() OVER (ORDER BY firstname) - 1 rn,
COUNT(*) OVER () AS tot
FROM my_contacts
) AS f_names
GROUP BY chunk, tot
ORDER BY name_range
60
150. Address Book
SELECT MIN(firstname) || ' - ' ||
MAX(firstname) AS name_range,
TRUNC(rn / 250) + 1 AS chunk,
COUNT(*) AS chunk_size,
tot
FROM (
SELECT firstname,
row_number() OVER (ORDER BY firstname) - 1 rn,
COUNT(*) OVER () AS tot
FROM my_contacts
) AS f_names
GROUP BY chunk, tot
ORDER BY name_range
60
151. Address Book
SELECT MIN(firstname) || ' - ' ||
MAX(firstname) AS name_range,
TRUNC(rn / 250) + 1 AS chunk,
COUNT(*) AS chunk_size,
tot
FROM (
SELECT firstname,
row_number() OVER (ORDER BY firstname) - 1 rn,
COUNT(*) OVER () AS tot
FROM my_contacts
) AS f_names
GROUP BY chunk, tot
ORDER BY name_range
60
152. Address Book
SELECT MIN(firstname) || ' - ' ||
MAX(firstname) AS name_range,
TRUNC(rn / 250) + 1 AS chunk,
COUNT(*) AS chunk_size,
tot
FROM (
SELECT firstname,
row_number() OVER (ORDER BY firstname) - 1 rn,
COUNT(*) OVER () AS tot
FROM my_contacts
) AS f_names
GROUP BY chunk, tot
ORDER BY name_range
60
154. Address Book
SELECT UPPER(SUBSTR(MIN(firstname), 1, 2)) || ' - ' ||
UPPER(SUBSTR(MAX(firstname), 1, 2))
AS name_range,
...
name_range chunk chunk_size tot
AA - AN 1 250 5494
AN - BE 2 250 5494
BE - CA 3 250 5494
... ... ... ...
VE - ZU 22 244 5494
62