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.
This document discusses PySpark DataFrames. It notes that DataFrames can be constructed from various data sources and are conceptually similar to tables in a relational database. The document explains that DataFrames allow richer optimizations than RDDs due to avoiding context switching between Java and Python. It provides links to resources that demonstrate how to create DataFrames, perform queries using DataFrame APIs and Spark SQL, and use an example flight data DataFrame.
Family tree of data – provenance and neo4jM. David Allen
The document discusses using Neo4j, a graph database, to store and query provenance data. Some key points:
- Storing provenance in a relational database requires complex SQL and pushes graph operations into code, hurting performance on graph queries.
- Neo4j uses the Cypher query language which allows declarative graph queries without imperative code.
- Example Cypher queries are provided to demonstrate retrieving paths and relationships in a provenance graph.
- While graph databases provide better performance for graph queries, they have limitations for certain bulk scans compared to relational databases. Proper graph design is important.
Ibm data science capstone project-SpaceX launch analysisHang (Henry) YAN
SpaceX advertises Falcon 9 rocket launches on its website, with a cost of 62 million dollars; other providers cost upward of 165 million dollars each, much of the savings is because
SpaceX can reuse the first stage. The project task is to predicting if the first stage of the SpaceX Falcon 9 rocket will land successfully. Data science methodologies have been applied to analyse launch data and optimise prediction of launches.
Max De Marzi gave an introduction to graph databases using Neo4j as an example. He discussed trends in big, connected data and how NoSQL databases like key-value stores, column families, and document databases address these trends. However, graph databases are optimized for interconnected data by modeling it as nodes and relationships. Neo4j is a graph database that uses a property graph data model and allows querying and traversal through its Cypher query language and Gremlin scripting language. It is well-suited for domains involving highly connected data like social networks.
The document provides an outline for a presentation on graph-based data models. It introduces some key concepts about graphs and how they are used to model real-world interconnected data. It discusses how early adopters of graph technologies grew by focusing on data relationships. The document also covers graph data structures, graph databases, and graph query languages like Cypher and Gremlin.
This document outlines an agenda and logistics for a training on Neo4j fundamentals and Cypher. It introduces graph concepts like nodes, relationships, and properties. It discusses why graphs are useful and shows examples of real-world domains that can be modeled as graphs. The training will cover introductory Cypher concepts like creating and matching patterns, and modeling exercises like representing a social network or movie genres graph. Logistics are provided like the WiFi password and a suggestion to work together in pairs on exercises.
Spark SQL Deep Dive @ Melbourne Spark MeetupDatabricks
This document summarizes a presentation on Spark SQL and its capabilities. Spark SQL allows users to run SQL queries on Spark, including HiveQL queries with UDFs, UDAFs, and SerDes. It provides a unified interface for reading and writing data in various formats. Spark SQL also allows users to express common operations like selecting columns, joining data, and aggregation concisely through its DataFrame API. This reduces the amount of code users need to write compared to lower-level APIs like RDDs.
This talk provides an in-depth overview of the key concepts of Apache Calcite. It explores the Calcite catalog, parsing, validation, and optimization with various planners.
Diese Präsentation zeigt das Oracle Portfolio im Bereich Ausfallsicherheit auf Oracle Datenbankebene. Ich habe sie 2012 erstellt und in verschiedenen Kundenwebcasts gezeigt.
With the rise of the Internet of Things (IoT) and low-latency analytics, streaming data becomes ever more important. Surprisingly, one of the most promising approaches for processing streaming data is SQL. In this presentation, Julian Hyde shows how to build streaming SQL analytics that deliver results with low latency, adapt to network changes, and play nicely with BI tools and stored data. He also describes how Apache Calcite optimizes streaming queries, and the ongoing collaborations between Calcite and the Storm, Flink and Samza projects.
This talk was given Julian Hyde at Apache Big Data conference, Vancouver, on 2016/05/09.
Convert BIM/ IFC models into graph database (Neo4j) based on IFCWebServer.orgAli Ismail
Application of graph databases and graph theory
concepts for advanced analysing of BIM models based
on IFC standard
=============================================
Utilizing graph theory concepts to explore, manage
and analyse all information inside BIM models
Knowledge Graphs & Graph Data Science, More Context, Better Predictions - Neo...Neo4j
The document discusses how knowledge graphs and graph data science can provide more context and enable better predictions. It provides examples of using knowledge graphs for interactive browsing of patent and pathway data, cross-species ontology graph queries, identifying relevant COVID-19 genes using graph algorithms, and sub-phenotyping patient populations using graph embeddings. The key message is that knowledge graphs harness relationships to provide deep, dynamic context for analytics and machine learning.
This document discusses different types of distributed databases. It covers data models like relational, aggregate-oriented, key-value, and document models. It also discusses different distribution models like sharding and replication. Consistency models for distributed databases are explained including eventual consistency and the CAP theorem. Key-value stores are described in more detail as a simple but widely used data model with features like consistency, scaling, and suitable use cases. Specific key-value databases like Redis, Riak, and DynamoDB are mentioned.
Challenges in Building a Data PipelineManish Kumar
The document discusses challenges in building a data pipeline including making it highly scalable, available with low latency and zero data loss while supporting multiple data sources. It covers expectations around real-time vs batch processing and streaming vs batch data. Implementation approaches like ETL vs ELT are examined along with replication modes, challenges around schema changes and NoSQL. Effective implementations should address transformations, security, replays, monitoring and more. Reference architectures like Lambda and Kappa are briefly outlined.
PySpark Programming | PySpark Concepts with Hands-On | PySpark Training | Edu...Edureka!
** PySpark Certification Training: https://www.edureka.co/pyspark-certification-training **
This Edureka tutorial on PySpark Programming will give you a complete insight of the various fundamental concepts of PySpark. Fundamental concepts include the following:
1. PySpark
2. RDDs
3. DataFrames
4. PySpark SQL
5. PySpark Streaming
6. Machine Learning (MLlib)
Choosing the Right Graph Database to Succeed in Your ProjectOntotext
The document discusses choosing the right graph database for projects. It describes Ontotext, a provider of graph database and semantic technology products. It outlines use cases for graph databases in areas like knowledge graphs, content management, and recommendations. The document then examines Ontotext's GraphDB semantic graph database product and how it can address key use cases. It provides guidance on choosing a GraphDB option based on project stage from learning to production.
Neo4j is a native graph database that allows organizations to leverage connections in data to create value in real-time. Unlike traditional databases, Neo4j connects data as it stores it, enabling lightning-fast retrieval of relationships. With over 200 customers including Walmart, UBS, and adidas, Neo4j is the number one database for connected data by providing a highly scalable and flexible platform to power use cases like recommendations, fraud detection, and supply chain management through relationship queries and analytics.
Spark is an open source cluster computing framework for large-scale data processing. It provides high-level APIs and runs on Hadoop clusters. Spark components include Spark Core for execution, Spark SQL for SQL queries, Spark Streaming for real-time data, and MLlib for machine learning. The core abstraction in Spark is the resilient distributed dataset (RDD), which allows data to be partitioned across nodes for parallel processing. A word count example demonstrates how to use transformations like flatMap and reduceByKey to count word frequencies from an input file in Spark.
Transforming AI with Graphs: Real World Examples using Spark and Neo4jDatabricks
Graphs – or information about the relationships, connection, and topology of data points – are transforming machine learning. We’ll walk through real world examples of how to get transform your tabular data into a graph and how to get started with graph AI. This talk will provide an overview of how we to incorporate graph based features into traditional machine learning pipelines, create graph embeddings to better describe your graph topology, and give you a preview of approaches for graph native learning using graph neural networks. We’ll talk about relevant, real world case studies in financial crime detection, recommendations, and drug discovery. This talk is intended to introduce the concept of graph based AI to beginners, as well as help practitioners understand new techniques and applications. Key take aways: how graph data can improve machine learning, when graphs are relevant to data science applications, what graph native learning is and how to get started.
This document summarizes key differences between relational and graph databases, how to model and query graph data using Neo4j, and provides an overview of popular graph database solutions including Neo4j, Titan, and AgensGraph. Relational databases use tables and rows to represent entities and relationships, while graph databases use nodes and edges. Graph queries can traverse relationships in variable lengths and have no concept of tables or joins.
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.
Scalable Architectures - Taming the Twitter FirehoseLorenzo Alberton
The document discusses scalable architectures for real-time platforms like Twitter. It covers using service-oriented architectures (SOAs) to scale individual components independently. Specific techniques discussed include using message queues like Redis and Kafka to decouple components and smooth load, caching with Varnish, load balancing with HAProxy, and distributing processing loads across worker processes using message patterns like ZeroMQ's PUSH-PULL. APIs and service discovery with Zookeeper are also covered. The overall goal is to scale all aspects of the platform.
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).
Implementing 3D SPHARM Surfaces Registration on Cell B.E. ProcessorPTIHPA
This document describes implementing 3D SPHARM surface registration on a Cell processor. It discusses SPHARM expansion and registration, calculating rotation coefficients, root mean square distance, and implementations in Matlab and on the Cell processor. The Cell implementation uses loop fusion, lookup tables, and optimizations for the Cell architecture like vectorization and data alignment. Performance analysis shows a dramatic increase in speed on the Cell due to its architecture and algorithm optimizations. Care is needed for data placement and transfer due to limited local store.
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
The document discusses reverse engineering and reversing crypto circuits. It provides examples of using a microscope at 500x magnification to analyze chip logic and using automated analysis to identify logic gates and trace wire connections. It also discusses reversing a recursive list-reverse function by defining a mutable list reverse function (mlist-reverse!) that mutably reverses a list without increasing memory usage based on list length. The instructor notes there are still unclaimed exams and storage fees will be charged starting Monday.
Exact Inference in Bayesian Networks using MapReduce (Hadoop Summit 2010)Alex Kozlov
This document discusses using MapReduce for exact Bayesian network inference. It provides background on Bayesian networks and their applications. It describes the CPCS network used for medical diagnosis that contains 422 nodes. Exact inference on this full network was previously impossible due to its large size, but MapReduce allows breaking the computation into smaller parallel pieces to solve it. The results show Bayesian network inference that previously took hours can now be done in minutes using Hadoop MapReduce.
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.
Lecture 3: Data-Intensive Computing for Text Analysis (Fall 2011)Matthew Lease
Here are a few reasons why using the reducer as the combiner doesn't work for computing the mean:
1. The reducer expects an iterator of values for a given key. But for the mean, we need to track the sum and count across all values for a key.
2. The reducer is called once per unique key. But to compute the mean, we need to track partial sums and counts across multiple invocations for the same key. There is no way to preserve state between calls to the reducer.
3. The reducer output type needs to match the mapper output type. But for the mean, the mapper emits (key, value) pairs while the reducer would need to emit (key, sum, count
This chapter discusses structured query language (SQL) and the relational database model. SQL allows users to interact with a relational database management system through commands to retrieve, insert, update, and delete data from tables. These commands include SELECT to query data, INSERT to add new rows, UPDATE to modify rows, and DELETE to remove rows. SQL also provides commands to define and modify the structure of tables using data definition language statements.
The document describes Threp, a lightweight remapping framework for use in Earth system models. Threp aims to provide a flexible, readable, and efficient framework for remapping data between different grid types, including regular, rectilinear, curvilinear, and unstructured grids. It supports operations like interpolation, masking, and extrapolation between source and destination grids. Threp uses a two-stage process of first generating interpolation weights and then applying those weights to remap data values. It is designed for parallel computation and to be easily extensible to support new interpolation methods and grid types.
This document summarizes a class on acceleration structures for ray tracing. It discusses building bounding volume hierarchies and using them to accelerate ray intersection tests. Uniform grids, kd-trees, and binary space partitioning trees are covered as approaches for spatial subdivision. The role of acceleration structures in speeding up global illumination calculations is also discussed.
The document discusses Bézier curves and provides information about a CS 354 class. It includes details about an in-class quiz, the professor's office hours, and an upcoming lecture on Bézier curves and Project 2, which is due on Friday. The lecture will cover procedural generation of a torus from a 2D grid, GLSL functions needed for the project, normal maps, coordinate spaces, interpolation curves, and Bézier curves.
State Equations Model Based On Modulo 2 Arithmetic And Its Applciation On Rec...Anax_Fotopoulos
1) The document discusses state equations that can model digital control systems based on modulo-2 arithmetic and their application to recursive convolutional coding.
2) Key concepts covered include cyclic groups, rings, state equations derived from transfer functions expressed in z-transform, and direct hardware realizations of state equations.
3) An example of a recursive convolutional encoder is described based on a set of recursive signal equations, and its corresponding algebraic state equations in modulo-2 arithmetic are provided.
State equations model based on modulo 2 arithmetic and its applciation on rec...Anax Fotopoulos
1) The document discusses state equations that can model digital control systems based on modulo-2 arithmetic and their application to recursive convolutional coding.
2) State equations can be derived from the transfer function of a discrete-time controller and expressed using modulo-2 arithmetic.
3) A recursive convolutional encoder can be modeled by state equations in modulo-2 algebra, where the state at each time step is a function of the previous states and the input bit.
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
The instruction set of the microcontroller includes arithmetic, logical, and flag-affecting instructions. It allows operations on registers, direct addresses, and indirect addresses. The instruction byte size and oscillator period required for each instruction is also provided in a table.
The instruction set summary provides concise information about the instructions of the AT89 microcontroller in a tabular format. The table lists instructions according to operation type and describes each instruction's mnemonic, operation performed, byte size, and oscillator period. A second table continues listing additional instructions.
The instruction set of the microcontroller includes arithmetic, logical, and flag-affecting instructions. It allows operations on registers, direct addresses, and indirect addresses. Common instructions include ADD, SUB, AND, OR, MOV, JMP, CALL. The instruction set supports conditional jumps based on flag settings from previous operations. Most instructions execute in 1 byte and 1 cycle.
The document provides information about a microcontroller instruction set including:
- Instructions that affect flag settings and how they modify the flags.
- The instruction set and addressing modes which include registers, direct addressing, indirect addressing, constants, and branches.
- A summary of the instruction set organized in a table with the opcode, instruction name, addressing mode, and byte size/cycle information.
The document discusses how computer scientists measure the cost of algorithms using asymptotic analysis. It introduces the big-O, Omega, and Theta notations to classify algorithms based on how their running time grows relative to the size of the input. Big-O represents an upper bound, Omega a lower bound, and Theta a tight bound of an algorithm's growth rate. The analysis allows abstracting away machine-specific details to understand an algorithm's fundamental performance properties.
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)
Generative AI technology is a fascinating field that focuses on creating comp...Nohoax Kanont
Generative AI technology is a fascinating field that focuses on creating computer models capable of generating new, original content. It leverages the power of large language models, neural networks, and machine learning to produce content that can mimic human creativity. This technology has seen a surge in innovation and adoption since the introduction of ChatGPT in 2022, leading to significant productivity benefits across various industries. With its ability to generate text, images, video, and audio, generative AI is transforming how we interact with technology and the types of tasks that can be automated.
Retrieval Augmented Generation Evaluation with RagasZilliz
Retrieval Augmented Generation (RAG) enhances chatbots by incorporating custom data in the prompt. Using large language models (LLMs) as judge has gained prominence in modern RAG systems. This talk will demo Ragas, an open-source automation tool for RAG evaluations. Christy will talk about and demo evaluating a RAG pipeline using Milvus and RAG metrics like context F1-score and answer correctness.
UiPath Community Day Amsterdam: Code, Collaborate, ConnectUiPathCommunity
Welcome to our third live UiPath Community Day Amsterdam! Come join us for a half-day of networking and UiPath Platform deep-dives, for devs and non-devs alike, in the middle of summer ☀.
📕 Agenda:
12:30 Welcome Coffee/Light Lunch ☕
13:00 Event opening speech
Ebert Knol, Managing Partner, Tacstone Technology
Jonathan Smith, UiPath MVP, RPA Lead, Ciphix
Cristina Vidu, Senior Marketing Manager, UiPath Community EMEA
Dion Mes, Principal Sales Engineer, UiPath
13:15 ASML: RPA as Tactical Automation
Tactical robotic process automation for solving short-term challenges, while establishing standard and re-usable interfaces that fit IT's long-term goals and objectives.
Yannic Suurmeijer, System Architect, ASML
13:30 PostNL: an insight into RPA at PostNL
Showcasing the solutions our automations have provided, the challenges we’ve faced, and the best practices we’ve developed to support our logistics operations.
Leonard Renne, RPA Developer, PostNL
13:45 Break (30')
14:15 Breakout Sessions: Round 1
Modern Document Understanding in the cloud platform: AI-driven UiPath Document Understanding
Mike Bos, Senior Automation Developer, Tacstone Technology
Process Orchestration: scale up and have your Robots work in harmony
Jon Smith, UiPath MVP, RPA Lead, Ciphix
UiPath Integration Service: connect applications, leverage prebuilt connectors, and set up customer connectors
Johans Brink, CTO, MvR digital workforce
15:00 Breakout Sessions: Round 2
Automation, and GenAI: practical use cases for value generation
Thomas Janssen, UiPath MVP, Senior Automation Developer, Automation Heroes
Human in the Loop/Action Center
Dion Mes, Principal Sales Engineer @UiPath
Improving development with coded workflows
Idris Janszen, Technical Consultant, Ilionx
15:45 End remarks
16:00 Community fun games, sharing knowledge, drinks, and bites 🍻
Welcome to Cyberbiosecurity. Because regular cybersecurity wasn't complicated...Snarky Security
How wonderful it is that in our modern age, every bit of our biological data can be digitized, stored, and potentially pilfered by cyber thieves! Isn't it just splendid to think that while scientists are busy pushing the boundaries of biotechnology, hackers could be plotting the next big bio-data heist? This delightful scenario is brought to you by the ever-expanding digital landscape of biology and biotechnology, where the integration of computer science, engineering, and data science transforms our understanding and manipulation of biological systems.
While the fusion of technology and biology offers immense benefits, it also necessitates a careful consideration of the ethical, security, and associated social implications. But let's be honest, in the grand scheme of things, what's a little risk compared to potential scientific achievements? After all, progress in biotechnology waits for no one, and we're just along for the ride in this thrilling, slightly terrifying, adventure.
So, as we continue to navigate this complex landscape, let's not forget the importance of robust data protection measures and collaborative international efforts to safeguard sensitive biological information. After all, what could possibly go wrong?
-------------------------
This document provides a comprehensive analysis of the security implications biological data use. The analysis explores various aspects of biological data security, including the vulnerabilities associated with data access, the potential for misuse by state and non-state actors, and the implications for national and transnational security. Key aspects considered include the impact of technological advancements on data security, the role of international policies in data governance, and the strategies for mitigating risks associated with unauthorized data access.
This view offers valuable insights for security professionals, policymakers, and industry leaders across various sectors, highlighting the importance of robust data protection measures and collaborative international efforts to safeguard sensitive biological information. The analysis serves as a crucial resource for understanding the complex dynamics at the intersection of biotechnology and security, providing actionable recommendations to enhance biosecurity in an digital and interconnected world.
The evolving landscape of biology and biotechnology, significantly influenced by advancements in computer science, engineering, and data science, is reshaping our understanding and manipulation of biological systems. The integration of these disciplines has led to the development of fields such as computational biology and synthetic biology, which utilize computational power and engineering principles to solve complex biological problems and innovate new biotechnological applications. This interdisciplinary approach has not only accelerated research and development but also introduced new capabilities such as gene editing and biomanufact
Discovery Series - Zero to Hero - Task Mining Session 1DianaGray10
This session is focused on providing you with an introduction to task mining. We will go over different types of task mining and provide you with a real-world demo on each type of task mining in detail.
Keynote : AI & Future Of Offensive SecurityPriyanka Aash
In the presentation, the focus is on the transformative impact of artificial intelligence (AI) in cybersecurity, particularly in the context of malware generation and adversarial attacks. AI promises to revolutionize the field by enabling scalable solutions to historically challenging problems such as continuous threat simulation, autonomous attack path generation, and the creation of sophisticated attack payloads. The discussions underscore how AI-powered tools like AI-based penetration testing can outpace traditional methods, enhancing security posture by efficiently identifying and mitigating vulnerabilities across complex attack surfaces. The use of AI in red teaming further amplifies these capabilities, allowing organizations to validate security controls effectively against diverse adversarial scenarios. These advancements not only streamline testing processes but also bolster defense strategies, ensuring readiness against evolving cyber threats.
Keynote : Presentation on SASE TechnologyPriyanka Aash
Secure Access Service Edge (SASE) solutions are revolutionizing enterprise networks by integrating SD-WAN with comprehensive security services. Traditionally, enterprises managed multiple point solutions for network and security needs, leading to complexity and resource-intensive operations. SASE, as defined by Gartner, consolidates these functions into a unified cloud-based service, offering SD-WAN capabilities alongside advanced security features like secure web gateways, CASB, and remote browser isolation. This convergence not only simplifies management but also enhances security posture and application performance across global networks and cloud environments. Discover how adopting SASE can streamline operations and fortify your enterprise's digital transformation strategy.
"Hands-on development experience using wasm Blazor", Furdak Vladyslav.pptxFwdays
I will share my personal experience of full-time development on wasm Blazor
What difficulties our team faced: life hacks with Blazor app routing, whether it is necessary to write JavaScript, which technology stack and architectural patterns we chose
What conclusions we made and what mistakes we committed
The Zaitechno Handheld Raman Spectrometer is a powerful and portable tool for rapid, non-destructive chemical analysis. It utilizes Raman spectroscopy, a technique that analyzes the vibrational fingerprint of molecules to identify their chemical composition. This handheld instrument allows for on-site analysis of materials, making it ideal for a variety of applications, including:
Material identification: Identify unknown materials, minerals, and contaminants.
Quality control: Ensure the quality and consistency of raw materials and finished products.
Pharmaceutical analysis: Verify the identity and purity of pharmaceutical compounds.
Food safety testing: Detect contaminants and adulterants in food products.
Field analysis: Analyze materials in the field, such as during environmental monitoring or forensic investigations.
The Zaitechno Handheld Raman Spectrometer is easy to use and features a user-friendly interface. It is compact and lightweight, making it ideal for field applications. With its rapid analysis capabilities, the Zaitechno Handheld Raman Spectrometer can help you improve efficiency and productivity in your research or quality control workflows.
The History of Embeddings & Multimodal EmbeddingsZilliz
Frank Liu will walk through the history of embeddings and how we got to the cool embedding models used today. He'll end with a demo on how multimodal RAG is used.
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