SlideShare ist ein Scribd-Unternehmen logo
1 von 23
Slick – The modern Way 
to query your Data! 
on 
Jogja Digital Valley 
Jochen Hülß 
01/10/2014 
The answer to life, 
the universe and 
everything?
• M.Sc. in Business Information Systems 
(Mannheim University) 
• Data Mining & Web Usage Mining 
• Cloud Technologies 
• 5 years with SAP 
(Business Software Vendor) 
• Business Intelligence 
• Android Development 
• Heinz-Nixdorf Fellowship-Program 
• Venture Capital Investment 
• Ideabox / Mountain SEA Ventures 
Bio of Jochen 
05/10/14 Slick – TechTalk #42 2
Prerequisites 
• Know about SQL 
• MVC Pattern 
• Collections in 
programming 
• Ask directly! 
Before and after 
Learning Goals 
• Explain, what Slick is 
used for. 
• Know about the 
advantages of Slick. 
• Know the basic 
commands used for 
querying in Slick. 
05/10/14 Slick – TechTalk #42 3
Motivation 
What is Slick all about? 
05/10/14 4
COFFEE 
ID NAME 
BUYER SALES 
SUP_ID 
(FK) 
PRICE AMOUNT 
SUPPLIER 
COF_ID 
(FK) 
ID NAME COUNTRY 
ID NAME COUNTRY FAV_COFFE_ID 
(FK) 
Imagine a simple Database schema… 
05/10/14 Slick – TechTalk #42 5
Browser 
HTML5 JavaScript CSS 
JSON 
Web Framework 
View Controller Model 
Database 
SQL 
How can we simplify 
the Database-Controller 
connection? 
… being used for a Web Application 
05/10/14 Slick – TechTalk #42 6
Modern database query & access library for Scala 
Scala Runtime 
Scala-Controller Slick-Model 
SQL 
PostgreSQL Database 
As a developer, I want to use Slick! 
05/10/14 Slick – TechTalk #42 8
• Easy 
• Database access just like Scala collections 
• Manages your Database sessions via JDBC 
• Supports plain SQL 
• Simple setup, many supported databases 
• Precise 
• Compile time safety 
• Query re-use with ease  Scala functions 
• Immutable collections 
• Stateless 
Features of Slick 
Slick makes DB 
access scalable! 
05/10/14 Slick – TechTalk #42 9
Under the Hood 
How does it work? 
05/10/14 10
Every DB table gets 
its own type classes 
Generate syntax 
tree for SQL query 
computation 
Slick‘s Lifted Query Processing 
 lifting 
05/10/14 Slick – TechTalk #42 11
1) /** Entity class storing rows of table Coffee */ 
2) case class CoffeeRow(id: Long, name: Option[String]) 
3) /** Table description of table coffee. Objects of this class serve as 
prototypes for rows in queries. */ 
4) class Coffee(tag: Tag) extends Table[CoffeeRow](tag, "coffee") { 
5) def * = (id, name) <> (CoffeeRow.tupled, CoffeeRow.unapply) 
6) val id: Column[Long] = column[Long]("id", O.AutoInc, O.PrimaryKey) 
7) val name: Column[Option[String]] = column[Option[String]]("name") 
8) } 
9) /** Collection-like TableQuery object for table Coffee */ 
10) lazy val Coffee = new TableQuery(tag => new Coffee(tag)) 
Example Code for Relation Coffee 
05/10/14 Slick – TechTalk #42 12
• Scala >2.10 
• Scala Build Tool >0.13 
• Add dependencies 
• Slick >2.0 
• Database specific driver 
• Import database driver 
 Many tutorials available 
Setup 
More Info: 
http://slick.typesafe. 
com/doc/2.0.1/getti 
ngstarted.html 
05/10/14 Slick – TechTalk #42 13
Getting started 
Schema Generation, Connection, Data inserts 
05/10/14 14
COFFEE 
ID NAME 
BUYER SALES 
SUP_ID 
(FK) 
PRICE AMOUNT 
SUPPLIER 
COF_ID 
(FK) 
ID NAME COUNTY 
ID NAME COUNTRY FAV_COFFE_ID 
(FK) 
Our sample Database schema 
05/10/14 Slick – TechTalk #42 15
Task 
1. Schema Generation 
2. Connection 
3. Data inserts 
Getting started 
Tips and Tricks 
• Use Slick‘s 
SourceCodeGenerator 
• Use wrapped connection 
object 
• Single or batch (faster) 
insert possible 
• ID return only with single 
05/10/14 Slick – TechTalk #42 16
Basic Queries 
Projection, Filtering, Sorting 
05/10/14 17
Task 
1. Projection 
1. Result list() 
2. Result foreach() 
3. Result first() 
2. Where 
3. Where with LIKE 
4. Where with AND / OR 
5. Sorting 
Basic Queries 
Tips and Tricks 
• “map()” iterates over collection 
• Result with “list()” in memory, 
with “foreach()” only temporary 
• If attribute is not “NOT NULL” on 
database  use “Option()” 
• Filter with “===“ 
• Use “toLowerCase()” with “like()” 
05/10/14 Slick – TechTalk #42 18
Advanced Queries 
Joins, Aggregates, nested Queries 
05/10/14 19
Task 
1. Inner Join 
2. Inner Join with 
condition 
3. Inner Join with foreign 
key 
4. Inner Join with 3 tables 
5. Aggregation and 
nested queries (I) 
6. Aggregation and 
nested queries (II) 
Advanced Queries 
Tips and Tricks 
• For-Loop connects two 
collections 
• Where conditions start with “if“ 
• Slick model provides helper for 
foreign key relations 
• “groupBy”  new collection with 
tuples 
• Aggregation max, min, sum, … 
• Use queries within other queries 
05/10/14 Slick – TechTalk #42 20
Conclusion 
Is Slick the answer to life, the universe and everything?! 
05/10/14 21
+ Production 
+ Level of 
control 
+ Lightweight 
Thoughts on Slick 
+ Usability in 
Scala 
- Generated 
Queries 
(readability) 
ready 
05/10/14 Slick – TechTalk #42 22
• http://slick.typesafe.com/doc/2.0.1/ 
• https://mackler.org/LearningSlick2/ 
• “Slick - The Structured Way” from SlideShare 
• “Brief introduction of Slick” from SlideShare 
References 
05/10/14 Slick – TechTalk #42 23
Thank you! 
Jogja Digital Valley 
Jochen Hülß (jochen@huelss.de) 
01/10/2014

Weitere ähnliche Inhalte

Was ist angesagt?

2016 Spark Summit East Keynote: Matei Zaharia
2016 Spark Summit East Keynote: Matei Zaharia2016 Spark Summit East Keynote: Matei Zaharia
2016 Spark Summit East Keynote: Matei ZahariaDatabricks
 
Machine Learning for the Apache Spark Developer with Paige Liu
Machine Learning for the Apache Spark Developer with Paige LiuMachine Learning for the Apache Spark Developer with Paige Liu
Machine Learning for the Apache Spark Developer with Paige LiuDatabricks
 
Elasticsearch and Spark
Elasticsearch and SparkElasticsearch and Spark
Elasticsearch and SparkAudible, Inc.
 
Correctness and Performance of Apache Spark SQL with Bogdan Ghit and Nicolas ...
Correctness and Performance of Apache Spark SQL with Bogdan Ghit and Nicolas ...Correctness and Performance of Apache Spark SQL with Bogdan Ghit and Nicolas ...
Correctness and Performance of Apache Spark SQL with Bogdan Ghit and Nicolas ...Databricks
 
Your Big Data Stack is Too Big!: Presented by Timothy Potter, Lucidworks
Your Big Data Stack is Too Big!: Presented by Timothy Potter, LucidworksYour Big Data Stack is Too Big!: Presented by Timothy Potter, Lucidworks
Your Big Data Stack is Too Big!: Presented by Timothy Potter, LucidworksLucidworks
 
Extending Apache Spark APIs Without Going Near Spark Source or a Compiler wi...
 Extending Apache Spark APIs Without Going Near Spark Source or a Compiler wi... Extending Apache Spark APIs Without Going Near Spark Source or a Compiler wi...
Extending Apache Spark APIs Without Going Near Spark Source or a Compiler wi...Databricks
 
Сергей Калинец "Не SQL-ом единым..."
Сергей Калинец "Не SQL-ом единым..."Сергей Калинец "Не SQL-ом единым..."
Сергей Калинец "Не SQL-ом единым..."Fwdays
 
ELK - Stack - Munich .net UG
ELK - Stack - Munich .net UGELK - Stack - Munich .net UG
ELK - Stack - Munich .net UGSteve Behrendt
 
Spark DataFrames: Simple and Fast Analytics on Structured Data at Spark Summi...
Spark DataFrames: Simple and Fast Analytics on Structured Data at Spark Summi...Spark DataFrames: Simple and Fast Analytics on Structured Data at Spark Summi...
Spark DataFrames: Simple and Fast Analytics on Structured Data at Spark Summi...Databricks
 
Real Time search using Spark and Elasticsearch
Real Time search using Spark and ElasticsearchReal Time search using Spark and Elasticsearch
Real Time search using Spark and ElasticsearchSigmoid
 
What to expect when you're Incubating
What to expect when you're IncubatingWhat to expect when you're Incubating
What to expect when you're IncubatingJulian Hyde
 
Spark Summit EU talk by Tim Hunter
Spark Summit EU talk by Tim HunterSpark Summit EU talk by Tim Hunter
Spark Summit EU talk by Tim HunterSpark Summit
 
How to Integrate Spark MLlib and Apache Solr to Build Real-Time Entity Type R...
How to Integrate Spark MLlib and Apache Solr to Build Real-Time Entity Type R...How to Integrate Spark MLlib and Apache Solr to Build Real-Time Entity Type R...
How to Integrate Spark MLlib and Apache Solr to Build Real-Time Entity Type R...Spark Summit
 
Dive into spark2
Dive into spark2Dive into spark2
Dive into spark2Gal Marder
 
Efficient Scalable Search in a Multi-Tenant Environment: Presented by Harry H...
Efficient Scalable Search in a Multi-Tenant Environment: Presented by Harry H...Efficient Scalable Search in a Multi-Tenant Environment: Presented by Harry H...
Efficient Scalable Search in a Multi-Tenant Environment: Presented by Harry H...Lucidworks
 
Being RDBMS Free -- Alternate Approaches to Data Persistence
Being RDBMS Free -- Alternate Approaches to Data PersistenceBeing RDBMS Free -- Alternate Approaches to Data Persistence
Being RDBMS Free -- Alternate Approaches to Data PersistenceDavid Hoerster
 
Spark Summit EU talk by Shay Nativ and Dvir Volk
Spark Summit EU talk by Shay Nativ and Dvir VolkSpark Summit EU talk by Shay Nativ and Dvir Volk
Spark Summit EU talk by Shay Nativ and Dvir VolkSpark Summit
 
Introduction to Apache Spark
Introduction to Apache SparkIntroduction to Apache Spark
Introduction to Apache SparkVincent Poncet
 

Was ist angesagt? (20)

2016 Spark Summit East Keynote: Matei Zaharia
2016 Spark Summit East Keynote: Matei Zaharia2016 Spark Summit East Keynote: Matei Zaharia
2016 Spark Summit East Keynote: Matei Zaharia
 
Machine Learning for the Apache Spark Developer with Paige Liu
Machine Learning for the Apache Spark Developer with Paige LiuMachine Learning for the Apache Spark Developer with Paige Liu
Machine Learning for the Apache Spark Developer with Paige Liu
 
Elasticsearch and Spark
Elasticsearch and SparkElasticsearch and Spark
Elasticsearch and Spark
 
Correctness and Performance of Apache Spark SQL with Bogdan Ghit and Nicolas ...
Correctness and Performance of Apache Spark SQL with Bogdan Ghit and Nicolas ...Correctness and Performance of Apache Spark SQL with Bogdan Ghit and Nicolas ...
Correctness and Performance of Apache Spark SQL with Bogdan Ghit and Nicolas ...
 
Your Big Data Stack is Too Big!: Presented by Timothy Potter, Lucidworks
Your Big Data Stack is Too Big!: Presented by Timothy Potter, LucidworksYour Big Data Stack is Too Big!: Presented by Timothy Potter, Lucidworks
Your Big Data Stack is Too Big!: Presented by Timothy Potter, Lucidworks
 
Solr4 nosql search_server_2013
Solr4 nosql search_server_2013Solr4 nosql search_server_2013
Solr4 nosql search_server_2013
 
Extending Apache Spark APIs Without Going Near Spark Source or a Compiler wi...
 Extending Apache Spark APIs Without Going Near Spark Source or a Compiler wi... Extending Apache Spark APIs Without Going Near Spark Source or a Compiler wi...
Extending Apache Spark APIs Without Going Near Spark Source or a Compiler wi...
 
Сергей Калинец "Не SQL-ом единым..."
Сергей Калинец "Не SQL-ом единым..."Сергей Калинец "Не SQL-ом единым..."
Сергей Калинец "Не SQL-ом единым..."
 
ELK - Stack - Munich .net UG
ELK - Stack - Munich .net UGELK - Stack - Munich .net UG
ELK - Stack - Munich .net UG
 
Spark DataFrames: Simple and Fast Analytics on Structured Data at Spark Summi...
Spark DataFrames: Simple and Fast Analytics on Structured Data at Spark Summi...Spark DataFrames: Simple and Fast Analytics on Structured Data at Spark Summi...
Spark DataFrames: Simple and Fast Analytics on Structured Data at Spark Summi...
 
Real Time search using Spark and Elasticsearch
Real Time search using Spark and ElasticsearchReal Time search using Spark and Elasticsearch
Real Time search using Spark and Elasticsearch
 
What to expect when you're Incubating
What to expect when you're IncubatingWhat to expect when you're Incubating
What to expect when you're Incubating
 
Spark Summit EU talk by Tim Hunter
Spark Summit EU talk by Tim HunterSpark Summit EU talk by Tim Hunter
Spark Summit EU talk by Tim Hunter
 
How to Integrate Spark MLlib and Apache Solr to Build Real-Time Entity Type R...
How to Integrate Spark MLlib and Apache Solr to Build Real-Time Entity Type R...How to Integrate Spark MLlib and Apache Solr to Build Real-Time Entity Type R...
How to Integrate Spark MLlib and Apache Solr to Build Real-Time Entity Type R...
 
Azure data lake sql konf 2016
Azure data lake   sql konf 2016Azure data lake   sql konf 2016
Azure data lake sql konf 2016
 
Dive into spark2
Dive into spark2Dive into spark2
Dive into spark2
 
Efficient Scalable Search in a Multi-Tenant Environment: Presented by Harry H...
Efficient Scalable Search in a Multi-Tenant Environment: Presented by Harry H...Efficient Scalable Search in a Multi-Tenant Environment: Presented by Harry H...
Efficient Scalable Search in a Multi-Tenant Environment: Presented by Harry H...
 
Being RDBMS Free -- Alternate Approaches to Data Persistence
Being RDBMS Free -- Alternate Approaches to Data PersistenceBeing RDBMS Free -- Alternate Approaches to Data Persistence
Being RDBMS Free -- Alternate Approaches to Data Persistence
 
Spark Summit EU talk by Shay Nativ and Dvir Volk
Spark Summit EU talk by Shay Nativ and Dvir VolkSpark Summit EU talk by Shay Nativ and Dvir Volk
Spark Summit EU talk by Shay Nativ and Dvir Volk
 
Introduction to Apache Spark
Introduction to Apache SparkIntroduction to Apache Spark
Introduction to Apache Spark
 

Ähnlich wie Slick – the modern way to access your Data

Jump Start with Apache Spark 2.0 on Databricks
Jump Start with Apache Spark 2.0 on DatabricksJump Start with Apache Spark 2.0 on Databricks
Jump Start with Apache Spark 2.0 on DatabricksAnyscale
 
Databricks for Dummies
Databricks for DummiesDatabricks for Dummies
Databricks for DummiesRodney Joyce
 
06 integrating extra features and looking forward
06   integrating extra features and looking forward06   integrating extra features and looking forward
06 integrating extra features and looking forwardМарина Босова
 
Not Your Father's Database by Databricks
Not Your Father's Database by DatabricksNot Your Father's Database by Databricks
Not Your Father's Database by DatabricksCaserta
 
Not Your Father's Database: How to Use Apache Spark Properly in Your Big Data...
Not Your Father's Database: How to Use Apache Spark Properly in Your Big Data...Not Your Father's Database: How to Use Apache Spark Properly in Your Big Data...
Not Your Father's Database: How to Use Apache Spark Properly in Your Big Data...Databricks
 
Not Your Father's Database by Vida Ha
Not Your Father's Database by Vida HaNot Your Father's Database by Vida Ha
Not Your Father's Database by Vida HaSpark Summit
 
Lightning Talk: Why and How to Integrate MongoDB and NoSQL into Hadoop Big Da...
Lightning Talk: Why and How to Integrate MongoDB and NoSQL into Hadoop Big Da...Lightning Talk: Why and How to Integrate MongoDB and NoSQL into Hadoop Big Da...
Lightning Talk: Why and How to Integrate MongoDB and NoSQL into Hadoop Big Da...MongoDB
 
Azure Synapse Analytics Overview (r2)
Azure Synapse Analytics Overview (r2)Azure Synapse Analytics Overview (r2)
Azure Synapse Analytics Overview (r2)James Serra
 
Extending Apache Spark SQL Data Source APIs with Join Push Down with Ioana De...
Extending Apache Spark SQL Data Source APIs with Join Push Down with Ioana De...Extending Apache Spark SQL Data Source APIs with Join Push Down with Ioana De...
Extending Apache Spark SQL Data Source APIs with Join Push Down with Ioana De...Databricks
 
Lightning Talk: Why and How to Integrate MongoDB and NoSQL into Hadoop Big Da...
Lightning Talk: Why and How to Integrate MongoDB and NoSQL into Hadoop Big Da...Lightning Talk: Why and How to Integrate MongoDB and NoSQL into Hadoop Big Da...
Lightning Talk: Why and How to Integrate MongoDB and NoSQL into Hadoop Big Da...MongoDB
 
Rajnish singh(presentation on oracle )
Rajnish singh(presentation on  oracle )Rajnish singh(presentation on  oracle )
Rajnish singh(presentation on oracle )Rajput Rajnish
 
Not your Father's Database: Not Your Father’s Database: How to Use Apache® Sp...
Not your Father's Database: Not Your Father’s Database: How to Use Apache® Sp...Not your Father's Database: Not Your Father’s Database: How to Use Apache® Sp...
Not your Father's Database: Not Your Father’s Database: How to Use Apache® Sp...Databricks
 
Framing the Argument: How to Scale Faster with NoSQL
Framing the Argument: How to Scale Faster with NoSQLFraming the Argument: How to Scale Faster with NoSQL
Framing the Argument: How to Scale Faster with NoSQLInside Analysis
 
The Evolution of the Oracle Database - Then, Now and Later (Fontys Hogeschool...
The Evolution of the Oracle Database - Then, Now and Later (Fontys Hogeschool...The Evolution of the Oracle Database - Then, Now and Later (Fontys Hogeschool...
The Evolution of the Oracle Database - Then, Now and Later (Fontys Hogeschool...Lucas Jellema
 

Ähnlich wie Slick – the modern way to access your Data (20)

Spark SQL
Spark SQLSpark SQL
Spark SQL
 
Jump Start with Apache Spark 2.0 on Databricks
Jump Start with Apache Spark 2.0 on DatabricksJump Start with Apache Spark 2.0 on Databricks
Jump Start with Apache Spark 2.0 on Databricks
 
Databricks for Dummies
Databricks for DummiesDatabricks for Dummies
Databricks for Dummies
 
06 integrating extra features and looking forward
06   integrating extra features and looking forward06   integrating extra features and looking forward
06 integrating extra features and looking forward
 
Not Your Father's Database by Databricks
Not Your Father's Database by DatabricksNot Your Father's Database by Databricks
Not Your Father's Database by Databricks
 
Not Your Father's Database: How to Use Apache Spark Properly in Your Big Data...
Not Your Father's Database: How to Use Apache Spark Properly in Your Big Data...Not Your Father's Database: How to Use Apache Spark Properly in Your Big Data...
Not Your Father's Database: How to Use Apache Spark Properly in Your Big Data...
 
Not Your Father's Database by Vida Ha
Not Your Father's Database by Vida HaNot Your Father's Database by Vida Ha
Not Your Father's Database by Vida Ha
 
ow.ppt
ow.pptow.ppt
ow.ppt
 
ow.ppt
ow.pptow.ppt
ow.ppt
 
Ow
OwOw
Ow
 
Lightning Talk: Why and How to Integrate MongoDB and NoSQL into Hadoop Big Da...
Lightning Talk: Why and How to Integrate MongoDB and NoSQL into Hadoop Big Da...Lightning Talk: Why and How to Integrate MongoDB and NoSQL into Hadoop Big Da...
Lightning Talk: Why and How to Integrate MongoDB and NoSQL into Hadoop Big Da...
 
Azure Synapse Analytics Overview (r2)
Azure Synapse Analytics Overview (r2)Azure Synapse Analytics Overview (r2)
Azure Synapse Analytics Overview (r2)
 
Extending Apache Spark SQL Data Source APIs with Join Push Down with Ioana De...
Extending Apache Spark SQL Data Source APIs with Join Push Down with Ioana De...Extending Apache Spark SQL Data Source APIs with Join Push Down with Ioana De...
Extending Apache Spark SQL Data Source APIs with Join Push Down with Ioana De...
 
Lightning Talk: Why and How to Integrate MongoDB and NoSQL into Hadoop Big Da...
Lightning Talk: Why and How to Integrate MongoDB and NoSQL into Hadoop Big Da...Lightning Talk: Why and How to Integrate MongoDB and NoSQL into Hadoop Big Da...
Lightning Talk: Why and How to Integrate MongoDB and NoSQL into Hadoop Big Da...
 
Rajnish singh(presentation on oracle )
Rajnish singh(presentation on  oracle )Rajnish singh(presentation on  oracle )
Rajnish singh(presentation on oracle )
 
70487.pdf
70487.pdf70487.pdf
70487.pdf
 
Not your Father's Database: Not Your Father’s Database: How to Use Apache® Sp...
Not your Father's Database: Not Your Father’s Database: How to Use Apache® Sp...Not your Father's Database: Not Your Father’s Database: How to Use Apache® Sp...
Not your Father's Database: Not Your Father’s Database: How to Use Apache® Sp...
 
Framing the Argument: How to Scale Faster with NoSQL
Framing the Argument: How to Scale Faster with NoSQLFraming the Argument: How to Scale Faster with NoSQL
Framing the Argument: How to Scale Faster with NoSQL
 
Plantilla oracle
Plantilla oraclePlantilla oracle
Plantilla oracle
 
The Evolution of the Oracle Database - Then, Now and Later (Fontys Hogeschool...
The Evolution of the Oracle Database - Then, Now and Later (Fontys Hogeschool...The Evolution of the Oracle Database - Then, Now and Later (Fontys Hogeschool...
The Evolution of the Oracle Database - Then, Now and Later (Fontys Hogeschool...
 

Kürzlich hochgeladen

WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile EnvironmentVictorSzoltysek
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 

Kürzlich hochgeladen (20)

WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 

Slick – the modern way to access your Data

  • 1. Slick – The modern Way to query your Data! on Jogja Digital Valley Jochen Hülß 01/10/2014 The answer to life, the universe and everything?
  • 2. • M.Sc. in Business Information Systems (Mannheim University) • Data Mining & Web Usage Mining • Cloud Technologies • 5 years with SAP (Business Software Vendor) • Business Intelligence • Android Development • Heinz-Nixdorf Fellowship-Program • Venture Capital Investment • Ideabox / Mountain SEA Ventures Bio of Jochen 05/10/14 Slick – TechTalk #42 2
  • 3. Prerequisites • Know about SQL • MVC Pattern • Collections in programming • Ask directly! Before and after Learning Goals • Explain, what Slick is used for. • Know about the advantages of Slick. • Know the basic commands used for querying in Slick. 05/10/14 Slick – TechTalk #42 3
  • 4. Motivation What is Slick all about? 05/10/14 4
  • 5. COFFEE ID NAME BUYER SALES SUP_ID (FK) PRICE AMOUNT SUPPLIER COF_ID (FK) ID NAME COUNTRY ID NAME COUNTRY FAV_COFFE_ID (FK) Imagine a simple Database schema… 05/10/14 Slick – TechTalk #42 5
  • 6. Browser HTML5 JavaScript CSS JSON Web Framework View Controller Model Database SQL How can we simplify the Database-Controller connection? … being used for a Web Application 05/10/14 Slick – TechTalk #42 6
  • 7. Modern database query & access library for Scala Scala Runtime Scala-Controller Slick-Model SQL PostgreSQL Database As a developer, I want to use Slick! 05/10/14 Slick – TechTalk #42 8
  • 8. • Easy • Database access just like Scala collections • Manages your Database sessions via JDBC • Supports plain SQL • Simple setup, many supported databases • Precise • Compile time safety • Query re-use with ease  Scala functions • Immutable collections • Stateless Features of Slick Slick makes DB access scalable! 05/10/14 Slick – TechTalk #42 9
  • 9. Under the Hood How does it work? 05/10/14 10
  • 10. Every DB table gets its own type classes Generate syntax tree for SQL query computation Slick‘s Lifted Query Processing  lifting 05/10/14 Slick – TechTalk #42 11
  • 11. 1) /** Entity class storing rows of table Coffee */ 2) case class CoffeeRow(id: Long, name: Option[String]) 3) /** Table description of table coffee. Objects of this class serve as prototypes for rows in queries. */ 4) class Coffee(tag: Tag) extends Table[CoffeeRow](tag, "coffee") { 5) def * = (id, name) <> (CoffeeRow.tupled, CoffeeRow.unapply) 6) val id: Column[Long] = column[Long]("id", O.AutoInc, O.PrimaryKey) 7) val name: Column[Option[String]] = column[Option[String]]("name") 8) } 9) /** Collection-like TableQuery object for table Coffee */ 10) lazy val Coffee = new TableQuery(tag => new Coffee(tag)) Example Code for Relation Coffee 05/10/14 Slick – TechTalk #42 12
  • 12. • Scala >2.10 • Scala Build Tool >0.13 • Add dependencies • Slick >2.0 • Database specific driver • Import database driver  Many tutorials available Setup More Info: http://slick.typesafe. com/doc/2.0.1/getti ngstarted.html 05/10/14 Slick – TechTalk #42 13
  • 13. Getting started Schema Generation, Connection, Data inserts 05/10/14 14
  • 14. COFFEE ID NAME BUYER SALES SUP_ID (FK) PRICE AMOUNT SUPPLIER COF_ID (FK) ID NAME COUNTY ID NAME COUNTRY FAV_COFFE_ID (FK) Our sample Database schema 05/10/14 Slick – TechTalk #42 15
  • 15. Task 1. Schema Generation 2. Connection 3. Data inserts Getting started Tips and Tricks • Use Slick‘s SourceCodeGenerator • Use wrapped connection object • Single or batch (faster) insert possible • ID return only with single 05/10/14 Slick – TechTalk #42 16
  • 16. Basic Queries Projection, Filtering, Sorting 05/10/14 17
  • 17. Task 1. Projection 1. Result list() 2. Result foreach() 3. Result first() 2. Where 3. Where with LIKE 4. Where with AND / OR 5. Sorting Basic Queries Tips and Tricks • “map()” iterates over collection • Result with “list()” in memory, with “foreach()” only temporary • If attribute is not “NOT NULL” on database  use “Option()” • Filter with “===“ • Use “toLowerCase()” with “like()” 05/10/14 Slick – TechTalk #42 18
  • 18. Advanced Queries Joins, Aggregates, nested Queries 05/10/14 19
  • 19. Task 1. Inner Join 2. Inner Join with condition 3. Inner Join with foreign key 4. Inner Join with 3 tables 5. Aggregation and nested queries (I) 6. Aggregation and nested queries (II) Advanced Queries Tips and Tricks • For-Loop connects two collections • Where conditions start with “if“ • Slick model provides helper for foreign key relations • “groupBy”  new collection with tuples • Aggregation max, min, sum, … • Use queries within other queries 05/10/14 Slick – TechTalk #42 20
  • 20. Conclusion Is Slick the answer to life, the universe and everything?! 05/10/14 21
  • 21. + Production + Level of control + Lightweight Thoughts on Slick + Usability in Scala - Generated Queries (readability) ready 05/10/14 Slick – TechTalk #42 22
  • 22. • http://slick.typesafe.com/doc/2.0.1/ • https://mackler.org/LearningSlick2/ • “Slick - The Structured Way” from SlideShare • “Brief introduction of Slick” from SlideShare References 05/10/14 Slick – TechTalk #42 23
  • 23. Thank you! Jogja Digital Valley Jochen Hülß (jochen@huelss.de) 01/10/2014

Hinweis der Redaktion

  1. + Lightweight + Level of control + Production ready Documentation Generated Queries (readability)