SlideShare a Scribd company logo
Implementing a many-to-many
Relationship with Slick
Implementing a many-to-many
Relationship with Slick
Author: Hermann Hueck
Source code and Slides available at:
https://github.com/hermannhueck/MusicService/tree/master/Services/MusicService-Play-Scala-Slick-NoAuth
http://de.slideshare.net/hermannhueck/implementing-a-manytomany-relationship-with-slick
Who am I?Who am I?
Hermann Hueck
Software Developer – Scala, Java, Akka, Play
https://www.xing.com/profile/Hermann_Hueck
Presentation OverviewPresentation Overview
● Short Intro to Slick
● Many-to-many Relationship with Slick –
Example: A Music Service
● Q & A
Part 1: Intro to SlickPart 1: Intro to Slick
● What is Slick?
● What is FRM (Functional Relational Mapping)?
● How to execute a database action?
● Why is it reactive?
● Short Reminder of Scala Futures
● Simple Slick Example (Activator Template: hello-slick-3.1)
● Table Definitions without and with Case Class Mapping
What is Slick?What is Slick?
The Slick manual says:
Slick (“Scala Language-Integrated Connection Kit”) is
Typesafe‘s Functional Relational Mapping (FRM) library for
Scala that makes it easy to work with relational databases. It
allows you to work with stored data almost as if you were
using Scala collections while at the same time giving you full
control over when a database access happens and which data
is transferred. You can also use SQL directly. Execution of
database actions is done asynchronously, making Slick a
perfect fit for your reactive applications based on Play and Akka.
What is FRM?What is FRM?
● FRM = Functional Relational Mapping (opposed to ORM)
● Slick allows you to process persistent relational data stored in
DB tables the same (functional) way as you do with in-memory
data, i.e. Scala collections.
● Table Queries are monads.
● Table Queries are pre-optimized.
● Table Queries are type-safe.
● The Scala compiler complains, if you specify your table query
incorrectly.
TableQuery s are Monads.TableQuery s are Monads.
● filter() for the selection of data
● map() for the projection
● flatMap() to pass the output of your 1st DB operation as input to the
2nd DB operation.
● With the provision of these three monadical functions TableQuery s
are monads.
● Hence you can also use the syntactic sugar of for-comprehensions.
● There is more. E.g. the sortBy() function allows you to define the
sort order of your query result.
How to execute a Slick DB Action?How to execute a Slick DB Action?
● Define a TableQuery
val query: Query[
] = TableQuery(
)

● For this TableQuery, define a database action which might be a query,
insert, bulk insert, update or a delete action or even a DDL action.
val dbAction: DBIO[
] = query += record // insert
val dbAction: DBIO[
] = query ++= Seq(row0, row1, 
, rowN) // bulk insert
val dbAction: DBIO[
] = query.update(valuesToUpdate) // update
val dbAction: DBIO[
] = query.delete // delete
val dbAction: DBIO[
] = query.result // insert
● Run the database action by calling db.run(dbAction). db.run never returns
the Result. You always get a Future[Result].
val dbAction: DBIO[
] = TableQuery(
).result
val future: Future[
] = db.run(dbAction)
Why is Slick reactive?Why is Slick reactive?
● It is asynchronous and non-blocking.
● It provides its own configurable thread pool.
● If you run a database action you never get the Result directly. You
always get a Future[Result].
val dbAction: DBIOAction[Seq[String]] = TableQuery(
).result
val future: Future[Seq[String]] = db.run( dbAction )
● Slick supports Reactive Streams. Hence it can easily be used together
with Akka-Streams (which is not subject of this talk).
val dbAction: StreamingDBIO[Seq[String]] = TableQuery(
).result
val publisher: DatabasePublisher[String] = db.stream( dbAction )
val source: Source = Source.fromPublisher( publisher )
// Now use the Source to construct a RunnableGraph. Then run the graph.
Short Reminder of Scala FuturesShort Reminder of Scala Futures
In Slick every database access returns a Future.
How can one async (DB) function process the result of another async
(DB) function?
This scenario happens very often when querying and manipulating
database records.
A very informative and understandable blog on Futures can be found
here:
http://danielwestheide.com/blog/2013/01/09/the-neophytes-guide-to-scala
-part-8-welcome-to-the-future.html
How to process the Result of an Async
Function by another Async Function
How to process the Result of an Async
Function by another Async Function
Using Future.flatMap:
def doAAsync(input: String): Future[A] = Future { val a = f(input); a }
def doBAsync(a: A): Future[B] = Future { val b = g(a); b }
val input = “some input“
val futureA: Future[A] = doAAsync(input)
val futureB: Future[B] = futureA flatMap { a => doBAsync(a) }
futureB.foreach { b => println(b) }
Async Function processing the
Result of another Async Function
Async Function processing the
Result of another Async Function
Using a for-comprehension:
def doAAsync(input: String): Future[A] = Future { val a = f(input); a }
def doBAsync(a: A): Future[B] = Future { val b = g(a); b }
val input = “some input“
val futureB: Future[B] = for {
a <- doAAsync(input)
b <- doBAsync(a)
} yield b
futureB.foreach { b => println(b) }
A Simple Slick ExampleA Simple Slick Example
Activator Template: hello-slick-3.1
Table Definition with a TupleTable Definition with a Tuple
class Users(tag: Tag) extends Table[(String, Option[Int])](tag, "USERS") {
// Auto Increment the id primary key column
def id = column[Int]("ID", O.PrimaryKey, O.AutoInc)
// The name can't be null
def name = column[String]("NAME", O.NotNull)
// the * projection (e.g. select * ...)
def * = (name, id.?)
}
Tuple
Table Definition with Case Class
Mapping
Table Definition with Case Class
Mapping
case class User(name: String, id: Option[Int] = None)
class Users(tag: Tag) extends Table[User](tag, "USERS") {
// Auto Increment the id primary key column
def id = column[Int]("ID", O.PrimaryKey, O.AutoInc)
// The name can't be null
def name = column[String]("NAME", O.NotNull)
// the * projection (e.g. select * ...) auto-transforms the tupled
// column values to / from a User
def * = (name, id.?) <> (User.tupled, User.unapply)
}
Map Tuple to User Map User to Tuple
Part 2: Many-to-many with SlickPart 2: Many-to-many with Slick
● The Demo App: MusicService
● Many-to-many Relationship (DB Schema)
● Web Application Demo
● Many-to-many in Slick Table Definitions
● Ensuring Referential Integrity
● Adding and Deleting Relationships
● Traversing the many-to-many Relationship in Queries
The Demo App: MusicServiceThe Demo App: MusicService
● The MusicService manages Music Recordings
and Performers.
● A Recording is performedBy many (0 
 n)
Performers.
● A Performer is performingIn many (0 
 n)
Recordings.
Many-to-many in the DB SchemaMany-to-many in the DB Schema
ID NAME PERFORMER_TYPE
1 Arthur Rubinstein Soloist
2 London Phil. Orch. Ensemble
3 Herbert von Karajan Conductor
4 Christopher Park Soloist
...
PERFORMERS
ID TITLE COMPOSER YEAR
1 Beethoven's Symphony No. 5 Ludwig v. Beethoven 2005
2 Forellenquintett Franz Schubert 2006
3 Eine kleine Nachtmusik Wolfgang Amadeus Mozart 2005
4 EntfĂŒhrung aus dem Serail Wolfgang Amadeus Mozart 2008
...
RECORDINGS
REC_ID PER_ID
1 1
1 2
1 3
3 1
... ...
RECORDINGS_PERFORMERS
Web Application DemoWeb Application Demo
MusicService is a Play Application with a rather primitive
UI. This interface allows the user to 

● Create, delete, update Performers and Recordings
● Assign Performers to Recordings or Recordings to
Performers and delete these Assignments
● Query / Search for Performers and Recordings
● Play Recordings
Many-to-many Relationship in the
Slick Table Definitions
Many-to-many Relationship in the
Slick Table Definitions
case class RecordingPerformer(recId: Long, perId: Long)
// Table 'RecordingsPerformers' mapped to case class 'RecordingPerformer' as join table to map
// the many-to-many relationship between Performers and Recordings
//
class RecordingsPerformers(tag: Tag)
extends Table[RecordingPerformer](tag, "RECORDINGS_PERFORMERS") {
def recId: Rep[Long] = column[Long]("REC_ID")
def perId: Rep[Long] = column[Long]("PER_ID")
def * = (recId, perId) <> (RecordingPerformer.tupled, RecordingPerformer.unapply)
def pk = primaryKey("primaryKey", (recId, perId))
def recFK = foreignKey("FK_RECORDINGS", recId, TableQuery[Recordings])(recording =>
recording.id, onDelete=ForeignKeyAction.Cascade)
def perFK = foreignKey("FK_PERFORMERS", perId, TableQuery[Performers])(performer =>
performer.id)
// onUpdate=ForeignKeyAction.Restrict is omitted as this is the default
}
Ensuring Referential IntegrityEnsuring Referential Integrity
● Referential Integrity is guaranteed by the definition of a foreignKey()
function in the referring table, which allows to navigate to the referred
table.
● You can optionally specify an onDelete action and an onUpdate
action, which has one of the following values:
 ForeignKeyAction.NoAction
 ForeignKeyAction.Restrict
 ForeignKeyAction.Cascade
 ForeignKeyAction.SetNull
 ForeignKeyAction.SetDefault
Adding and Deleting RelationshipsAdding and Deleting Relationships
● Adding a concrete relationship == Adding an
entry into the Mapping Table, if it doesn't
already exist.
● Deleting a concrete relationship == Deleting an
entry from the Mapping Table, if it exists.
● Updates in the Mapping Table do not make
much sense. Hence I do not support them im
my implementation.
Traversing many-to-many the
Relationship in Queries
Traversing many-to-many the
Relationship in Queries
● The Query.join() function allows you to perform an inner
join on tables.
● The Query.on() function allows you to perform an inner
join on tables.
● Example:
val query = TableQuery[Performers] join TableQuery[RecordingsPerformers] on (_.id === _.perId)
val future: Future[Seq[(Performer, RecordingPerformer)]] = db.run { query.result }
// Now postprocess this future with filter, map, flatMap etc.
// Especially filter the result for a specific recording id.
Thank you for listening!
Q & A
ResourcesResources
● Slick Website:
http://slick.typesafe.com/doc/3.1.1/
● Slick Activator Template Website with Tutorial:
https://www.typesafe.com/activator/template/hello-slick-3.1
● Slick Activator Template Source Code:
https://github.com/typesafehub/activator-hello-slick#slick-3.1
● A very informative blog on Futures:
http://danielwestheide.com/blog/2013/01/09/the-neophytes-guide-to-scala-part-8-welcome-to-the-
future.html
● MusicService Source Code and Slides at Github:
https://github.com/hermannhueck/MusicService/tree/master/Services/MusicService-Play-Scala-S
lick-NoAuth
● MusicService Slides at SlideShare:
http://de.slideshare.net/hermannhueck/implementing-a-manytomany-relationship-with-slick
● Authors XING Profile:
https://www.xing.com/profile/Hermann_Hueck
Ad

More Related Content

What's hot (20)

GiáșŁi phĂĄp báșŁo máș­t vĂ  xĂĄc thá»±c thư điện tá»­ dá»±a trĂȘn cĂŽng nghệ mở
GiáșŁi phĂĄp báșŁo máș­t vĂ  xĂĄc thá»±c thư điện tá»­ dá»±a trĂȘn cĂŽng nghệ mởGiáșŁi phĂĄp báșŁo máș­t vĂ  xĂĄc thá»±c thư điện tá»­ dá»±a trĂȘn cĂŽng nghệ mở
GiáșŁi phĂĄp báșŁo máș­t vĂ  xĂĄc thá»±c thư điện tá»­ dá»±a trĂȘn cĂŽng nghệ mở
Dịch vỄ viáșżt bĂ i trọn gĂłi ZALO: 0909232620
 
BĂ i GiáșŁng QuáșŁn LĂœ Tiáșżn TrĂŹnh Trong Hệ Điều HĂ nh
BĂ i GiáșŁng QuáșŁn LĂœ Tiáșżn TrĂŹnh Trong Hệ Điều HĂ nh BĂ i GiáșŁng QuáșŁn LĂœ Tiáșżn TrĂŹnh Trong Hệ Điều HĂ nh
BĂ i GiáșŁng QuáșŁn LĂœ Tiáșżn TrĂŹnh Trong Hệ Điều HĂ nh
nataliej4
 
Redux Thunk
Redux ThunkRedux Thunk
Redux Thunk
ASIMYILDIZ
 
Ká»č thuáș­t giáș„u tin văn báșŁn trong hĂŹnh áșŁnh dá»±a trĂȘn hĂ m modulus
Ká»č thuáș­t giáș„u tin văn báșŁn trong hĂŹnh áșŁnh dá»±a trĂȘn hĂ m modulusKá»č thuáș­t giáș„u tin văn báșŁn trong hĂŹnh áșŁnh dá»±a trĂȘn hĂ m modulus
Ká»č thuáș­t giáș„u tin văn báșŁn trong hĂŹnh áșŁnh dá»±a trĂȘn hĂ m modulus
Dịch vỄ viáșżt bĂ i trọn gĂłi ZALO 0917193864
 
BĂ i 2 : CĂĄc đối tÆ°á»Łng trong CSDL - SQL server
BĂ i 2 : CĂĄc đối tÆ°á»Łng trong CSDL - SQL serverBĂ i 2 : CĂĄc đối tÆ°á»Łng trong CSDL - SQL server
BĂ i 2 : CĂĄc đối tÆ°á»Łng trong CSDL - SQL server
MasterCode.vn
 
Luáș­n văn TháșĄc sÄ© NghiĂȘn cứu triển khai giáșŁi phĂĄp đáșŁm báșŁo an ninh máșĄng trĂȘn nề...
Luáș­n văn TháșĄc sÄ© NghiĂȘn cứu triển khai giáșŁi phĂĄp đáșŁm báșŁo an ninh máșĄng trĂȘn nề...Luáș­n văn TháșĄc sÄ© NghiĂȘn cứu triển khai giáșŁi phĂĄp đáșŁm báșŁo an ninh máșĄng trĂȘn nề...
Luáș­n văn TháșĄc sÄ© NghiĂȘn cứu triển khai giáșŁi phĂĄp đáșŁm báșŁo an ninh máșĄng trĂȘn nề...
Dịch vỄ viáșżt thuĂȘ Luáș­n Văn - ZALO 0932091562
 
ỚNG DỀNG DEEP LEARNING ĐỂ ĐáșŸM SỐ LÆŻá»ąNG XE ÔTÔ TRONG NỘI THÀNH ĐÀ NáșŽNG 51920ed2
ỚNG DỀNG DEEP LEARNING ĐỂ ĐáșŸM SỐ LÆŻá»ąNG XE ÔTÔ TRONG NỘI THÀNH ĐÀ NáșŽNG 51920ed2ỚNG DỀNG DEEP LEARNING ĐỂ ĐáșŸM SỐ LÆŻá»ąNG XE ÔTÔ TRONG NỘI THÀNH ĐÀ NáșŽNG 51920ed2
ỚNG DỀNG DEEP LEARNING ĐỂ ĐáșŸM SỐ LÆŻá»ąNG XE ÔTÔ TRONG NỘI THÀNH ĐÀ NáșŽNG 51920ed2
nataliej4
 
NghiĂȘn cứu vĂ  hướng dáș«n sá»­ dỄng bộ cĂŽng cỄ quĂ©t lỗ hổng hệ thống trong máșĄng lan
NghiĂȘn cứu vĂ  hướng dáș«n sá»­ dỄng bộ cĂŽng cỄ quĂ©t lỗ hổng hệ thống trong máșĄng lanNghiĂȘn cứu vĂ  hướng dáș«n sá»­ dỄng bộ cĂŽng cỄ quĂ©t lỗ hổng hệ thống trong máșĄng lan
NghiĂȘn cứu vĂ  hướng dáș«n sá»­ dỄng bộ cĂŽng cỄ quĂ©t lỗ hổng hệ thống trong máșĄng lan
leokidd
 
MáșĄng neuron, trĂ­ tuệ nhĂąn táșĄo
MáșĄng neuron, trĂ­ tuệ nhĂąn táșĄoMáșĄng neuron, trĂ­ tuệ nhĂąn táșĄo
MáșĄng neuron, trĂ­ tuệ nhĂąn táșĄo
Kien Nguyen
 
Perangkat dalam keamanan jaringan
Perangkat dalam keamanan jaringanPerangkat dalam keamanan jaringan
Perangkat dalam keamanan jaringan
Dita Tri Utami
 
Rsa archer 6.9 platform installation and upgrade guide (3)
Rsa archer 6.9 platform installation and upgrade guide (3)Rsa archer 6.9 platform installation and upgrade guide (3)
Rsa archer 6.9 platform installation and upgrade guide (3)
AnkurGarg165647
 
Luan van hadoop-final
Luan van hadoop-finalLuan van hadoop-final
Luan van hadoop-final
nobjta2015
 
Danh SĂĄch 200 Đề TĂ i Luáș­n Văn An Ninh MáșĄng, Hay Nháș„t.docx
Danh SĂĄch 200 Đề TĂ i Luáș­n Văn An Ninh MáșĄng, Hay Nháș„t.docxDanh SĂĄch 200 Đề TĂ i Luáș­n Văn An Ninh MáșĄng, Hay Nháș„t.docx
Danh SĂĄch 200 Đề TĂ i Luáș­n Văn An Ninh MáșĄng, Hay Nháș„t.docx
Dịch vỄ viáșżt thuĂȘ đề tĂ i trọn gĂłi ☎☎☎ LiĂȘn hệ ZALO/TELE: 0973.287.149 👍👍
 
Chữ kĂœ số Digital Signature.pptx
Chữ kĂœ số Digital Signature.pptxChữ kĂœ số Digital Signature.pptx
Chữ kĂœ số Digital Signature.pptx
ssuserf23293
 
Snort it-slideshares.blogspot.com
Snort it-slideshares.blogspot.comSnort it-slideshares.blogspot.com
Snort it-slideshares.blogspot.com
phanleson
 
CNIT 127: Ch 18: Source Code Auditing
CNIT 127: Ch 18: Source Code AuditingCNIT 127: Ch 18: Source Code Auditing
CNIT 127: Ch 18: Source Code Auditing
Sam Bowne
 
NghiĂȘn cứu xĂąy dá»±ng ứng dỄng báșŁo máș­t VoIP trĂȘn HĐH Android
NghiĂȘn cứu xĂąy dá»±ng ứng dỄng báșŁo máș­t VoIP trĂȘn HĐH AndroidNghiĂȘn cứu xĂąy dá»±ng ứng dỄng báșŁo máș­t VoIP trĂȘn HĐH Android
NghiĂȘn cứu xĂąy dá»±ng ứng dỄng báșŁo máș­t VoIP trĂȘn HĐH Android
Nguyễn Tuáș„n
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni GarcĂ­a
 
He thong phat hien xam nhap IDS
He thong phat hien xam nhap IDSHe thong phat hien xam nhap IDS
He thong phat hien xam nhap IDS
Bui Loc
 
XĂąy dá»±ng website theo dĂ”i việc cáș„p báș±ng, chứng chỉ cho sinh viĂȘn
XĂąy dá»±ng website theo dĂ”i việc cáș„p báș±ng, chứng chỉ cho sinh viĂȘn XĂąy dá»±ng website theo dĂ”i việc cáș„p báș±ng, chứng chỉ cho sinh viĂȘn
XĂąy dá»±ng website theo dĂ”i việc cáș„p báș±ng, chứng chỉ cho sinh viĂȘn
Dịch vỄ viáșżt bĂ i trọn gĂłi ZALO: 0909232620
 
GiáșŁi phĂĄp báșŁo máș­t vĂ  xĂĄc thá»±c thư điện tá»­ dá»±a trĂȘn cĂŽng nghệ mở
GiáșŁi phĂĄp báșŁo máș­t vĂ  xĂĄc thá»±c thư điện tá»­ dá»±a trĂȘn cĂŽng nghệ mởGiáșŁi phĂĄp báșŁo máș­t vĂ  xĂĄc thá»±c thư điện tá»­ dá»±a trĂȘn cĂŽng nghệ mở
GiáșŁi phĂĄp báșŁo máș­t vĂ  xĂĄc thá»±c thư điện tá»­ dá»±a trĂȘn cĂŽng nghệ mở
Dịch vỄ viáșżt bĂ i trọn gĂłi ZALO: 0909232620
 
BĂ i GiáșŁng QuáșŁn LĂœ Tiáșżn TrĂŹnh Trong Hệ Điều HĂ nh
BĂ i GiáșŁng QuáșŁn LĂœ Tiáșżn TrĂŹnh Trong Hệ Điều HĂ nh BĂ i GiáșŁng QuáșŁn LĂœ Tiáșżn TrĂŹnh Trong Hệ Điều HĂ nh
BĂ i GiáșŁng QuáșŁn LĂœ Tiáșżn TrĂŹnh Trong Hệ Điều HĂ nh
nataliej4
 
Redux Thunk
Redux ThunkRedux Thunk
Redux Thunk
ASIMYILDIZ
 
BĂ i 2 : CĂĄc đối tÆ°á»Łng trong CSDL - SQL server
BĂ i 2 : CĂĄc đối tÆ°á»Łng trong CSDL - SQL serverBĂ i 2 : CĂĄc đối tÆ°á»Łng trong CSDL - SQL server
BĂ i 2 : CĂĄc đối tÆ°á»Łng trong CSDL - SQL server
MasterCode.vn
 
Luáș­n văn TháșĄc sÄ© NghiĂȘn cứu triển khai giáșŁi phĂĄp đáșŁm báșŁo an ninh máșĄng trĂȘn nề...
Luáș­n văn TháșĄc sÄ© NghiĂȘn cứu triển khai giáșŁi phĂĄp đáșŁm báșŁo an ninh máșĄng trĂȘn nề...Luáș­n văn TháșĄc sÄ© NghiĂȘn cứu triển khai giáșŁi phĂĄp đáșŁm báșŁo an ninh máșĄng trĂȘn nề...
Luáș­n văn TháșĄc sÄ© NghiĂȘn cứu triển khai giáșŁi phĂĄp đáșŁm báșŁo an ninh máșĄng trĂȘn nề...
Dịch vỄ viáșżt thuĂȘ Luáș­n Văn - ZALO 0932091562
 
ỚNG DỀNG DEEP LEARNING ĐỂ ĐáșŸM SỐ LÆŻá»ąNG XE ÔTÔ TRONG NỘI THÀNH ĐÀ NáșŽNG 51920ed2
ỚNG DỀNG DEEP LEARNING ĐỂ ĐáșŸM SỐ LÆŻá»ąNG XE ÔTÔ TRONG NỘI THÀNH ĐÀ NáșŽNG 51920ed2ỚNG DỀNG DEEP LEARNING ĐỂ ĐáșŸM SỐ LÆŻá»ąNG XE ÔTÔ TRONG NỘI THÀNH ĐÀ NáșŽNG 51920ed2
ỚNG DỀNG DEEP LEARNING ĐỂ ĐáșŸM SỐ LÆŻá»ąNG XE ÔTÔ TRONG NỘI THÀNH ĐÀ NáșŽNG 51920ed2
nataliej4
 
NghiĂȘn cứu vĂ  hướng dáș«n sá»­ dỄng bộ cĂŽng cỄ quĂ©t lỗ hổng hệ thống trong máșĄng lan
NghiĂȘn cứu vĂ  hướng dáș«n sá»­ dỄng bộ cĂŽng cỄ quĂ©t lỗ hổng hệ thống trong máșĄng lanNghiĂȘn cứu vĂ  hướng dáș«n sá»­ dỄng bộ cĂŽng cỄ quĂ©t lỗ hổng hệ thống trong máșĄng lan
NghiĂȘn cứu vĂ  hướng dáș«n sá»­ dỄng bộ cĂŽng cỄ quĂ©t lỗ hổng hệ thống trong máșĄng lan
leokidd
 
MáșĄng neuron, trĂ­ tuệ nhĂąn táșĄo
MáșĄng neuron, trĂ­ tuệ nhĂąn táșĄoMáșĄng neuron, trĂ­ tuệ nhĂąn táșĄo
MáșĄng neuron, trĂ­ tuệ nhĂąn táșĄo
Kien Nguyen
 
Perangkat dalam keamanan jaringan
Perangkat dalam keamanan jaringanPerangkat dalam keamanan jaringan
Perangkat dalam keamanan jaringan
Dita Tri Utami
 
Rsa archer 6.9 platform installation and upgrade guide (3)
Rsa archer 6.9 platform installation and upgrade guide (3)Rsa archer 6.9 platform installation and upgrade guide (3)
Rsa archer 6.9 platform installation and upgrade guide (3)
AnkurGarg165647
 
Luan van hadoop-final
Luan van hadoop-finalLuan van hadoop-final
Luan van hadoop-final
nobjta2015
 
Chữ kĂœ số Digital Signature.pptx
Chữ kĂœ số Digital Signature.pptxChữ kĂœ số Digital Signature.pptx
Chữ kĂœ số Digital Signature.pptx
ssuserf23293
 
Snort it-slideshares.blogspot.com
Snort it-slideshares.blogspot.comSnort it-slideshares.blogspot.com
Snort it-slideshares.blogspot.com
phanleson
 
CNIT 127: Ch 18: Source Code Auditing
CNIT 127: Ch 18: Source Code AuditingCNIT 127: Ch 18: Source Code Auditing
CNIT 127: Ch 18: Source Code Auditing
Sam Bowne
 
NghiĂȘn cứu xĂąy dá»±ng ứng dỄng báșŁo máș­t VoIP trĂȘn HĐH Android
NghiĂȘn cứu xĂąy dá»±ng ứng dỄng báșŁo máș­t VoIP trĂȘn HĐH AndroidNghiĂȘn cứu xĂąy dá»±ng ứng dỄng báșŁo máș­t VoIP trĂȘn HĐH Android
NghiĂȘn cứu xĂąy dá»±ng ứng dỄng báșŁo máș­t VoIP trĂȘn HĐH Android
Nguyễn Tuáș„n
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni GarcĂ­a
 
He thong phat hien xam nhap IDS
He thong phat hien xam nhap IDSHe thong phat hien xam nhap IDS
He thong phat hien xam nhap IDS
Bui Loc
 

Viewers also liked (13)

Using Scala Slick at FortyTwo
Using Scala Slick at FortyTwoUsing Scala Slick at FortyTwo
Using Scala Slick at FortyTwo
Eishay Smith
 
Draw More, Work Less
Draw More, Work LessDraw More, Work Less
Draw More, Work Less
Michael Bar-Sinai
 
Sharing Sensitive Data With Confidence: The DataTags system
Sharing Sensitive Data With Confidence: The DataTags systemSharing Sensitive Data With Confidence: The DataTags system
Sharing Sensitive Data With Confidence: The DataTags system
Michael Bar-Sinai
 
Introduction of Lianjia China
Introduction of Lianjia ChinaIntroduction of Lianjia China
Introduction of Lianjia China
Gabriel Shen
 
Reactive Access to MongoDB from Scala
Reactive Access to MongoDB from ScalaReactive Access to MongoDB from Scala
Reactive Access to MongoDB from Scala
Hermann Hueck
 
Slick - The Structured Way
Slick - The Structured WaySlick - The Structured Way
Slick - The Structured Way
Yennick Trevels
 
Slick: Bringing Scala’s Powerful Features to Your Database Access
Slick: Bringing Scala’s Powerful Features to Your Database Access Slick: Bringing Scala’s Powerful Features to Your Database Access
Slick: Bringing Scala’s Powerful Features to Your Database Access
Rebecca Grenier
 
Patterns for slick database applications
Patterns for slick database applicationsPatterns for slick database applications
Patterns for slick database applications
Skills Matter
 
A Deeper Look Into Reactive Streams with Akka Streams 1.0 and Slick 3.0
A Deeper Look Into Reactive Streams with Akka Streams 1.0 and Slick 3.0A Deeper Look Into Reactive Streams with Akka Streams 1.0 and Slick 3.0
A Deeper Look Into Reactive Streams with Akka Streams 1.0 and Slick 3.0
Legacy Typesafe (now Lightbend)
 
Reactive database access with Slick3
Reactive database access with Slick3Reactive database access with Slick3
Reactive database access with Slick3
takezoe
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and Scala
Yevgeniy Brikman
 
バッチを Akka Streams ăŠă‚™ć†ćźŸèŁ…ă—ăŸă‚‰100怍速くăȘăŁăŸè©± #ScalaMatsuri
バッチを Akka Streams ăŠă‚™ć†ćźŸèŁ…ă—ăŸă‚‰100怍速くăȘăŁăŸè©± #ScalaMatsuriバッチを Akka Streams ăŠă‚™ć†ćźŸèŁ…ă—ăŸă‚‰100怍速くăȘăŁăŸè©± #ScalaMatsuri
バッチを Akka Streams ăŠă‚™ć†ćźŸèŁ…ă—ăŸă‚‰100怍速くăȘăŁăŸè©± #ScalaMatsuri
Kazuki Negoro
 
the evolution of data infrastructure at lianjia
the evolution of data infrastructure at lianjiathe evolution of data infrastructure at lianjia
the evolution of data infrastructure at lianjia
æŻ… 搕
 
Using Scala Slick at FortyTwo
Using Scala Slick at FortyTwoUsing Scala Slick at FortyTwo
Using Scala Slick at FortyTwo
Eishay Smith
 
Sharing Sensitive Data With Confidence: The DataTags system
Sharing Sensitive Data With Confidence: The DataTags systemSharing Sensitive Data With Confidence: The DataTags system
Sharing Sensitive Data With Confidence: The DataTags system
Michael Bar-Sinai
 
Introduction of Lianjia China
Introduction of Lianjia ChinaIntroduction of Lianjia China
Introduction of Lianjia China
Gabriel Shen
 
Reactive Access to MongoDB from Scala
Reactive Access to MongoDB from ScalaReactive Access to MongoDB from Scala
Reactive Access to MongoDB from Scala
Hermann Hueck
 
Slick - The Structured Way
Slick - The Structured WaySlick - The Structured Way
Slick - The Structured Way
Yennick Trevels
 
Slick: Bringing Scala’s Powerful Features to Your Database Access
Slick: Bringing Scala’s Powerful Features to Your Database Access Slick: Bringing Scala’s Powerful Features to Your Database Access
Slick: Bringing Scala’s Powerful Features to Your Database Access
Rebecca Grenier
 
Patterns for slick database applications
Patterns for slick database applicationsPatterns for slick database applications
Patterns for slick database applications
Skills Matter
 
A Deeper Look Into Reactive Streams with Akka Streams 1.0 and Slick 3.0
A Deeper Look Into Reactive Streams with Akka Streams 1.0 and Slick 3.0A Deeper Look Into Reactive Streams with Akka Streams 1.0 and Slick 3.0
A Deeper Look Into Reactive Streams with Akka Streams 1.0 and Slick 3.0
Legacy Typesafe (now Lightbend)
 
Reactive database access with Slick3
Reactive database access with Slick3Reactive database access with Slick3
Reactive database access with Slick3
takezoe
 
Play Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and ScalaPlay Framework: async I/O with Java and Scala
Play Framework: async I/O with Java and Scala
Yevgeniy Brikman
 
バッチを Akka Streams ăŠă‚™ć†ćźŸèŁ…ă—ăŸă‚‰100怍速くăȘăŁăŸè©± #ScalaMatsuri
バッチを Akka Streams ăŠă‚™ć†ćźŸèŁ…ă—ăŸă‚‰100怍速くăȘăŁăŸè©± #ScalaMatsuriバッチを Akka Streams ăŠă‚™ć†ćźŸèŁ…ă—ăŸă‚‰100怍速くăȘăŁăŸè©± #ScalaMatsuri
バッチを Akka Streams ăŠă‚™ć†ćźŸèŁ…ă—ăŸă‚‰100怍速くăȘăŁăŸè©± #ScalaMatsuri
Kazuki Negoro
 
the evolution of data infrastructure at lianjia
the evolution of data infrastructure at lianjiathe evolution of data infrastructure at lianjia
the evolution of data infrastructure at lianjia
æŻ… 搕
 
Ad

Similar to Implementing a many-to-many Relationship with Slick (20)

A Recovering Java Developer Learns to Go
A Recovering Java Developer Learns to GoA Recovering Java Developer Learns to Go
A Recovering Java Developer Learns to Go
Matt Stine
 
Talk - Query monad
Talk - Query monad Talk - Query monad
Talk - Query monad
Fabernovel
 
PofEAA and SQLAlchemy
PofEAA and SQLAlchemyPofEAA and SQLAlchemy
PofEAA and SQLAlchemy
Inada Naoki
 
Lobos Introduction
Lobos IntroductionLobos Introduction
Lobos Introduction
Nicolas Buduroi
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
Dmitry Buzdin
 
Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)
Jonathan Felch
 
Seattle useR Group - R + Scala
Seattle useR Group - R + ScalaSeattle useR Group - R + Scala
Seattle useR Group - R + Scala
Shouheng Yi
 
Pune Clojure Course Outline
Pune Clojure Course OutlinePune Clojure Course Outline
Pune Clojure Course Outline
Baishampayan Ghose
 
The GO Language : From Beginners to Gophers
The GO Language : From Beginners to GophersThe GO Language : From Beginners to Gophers
The GO Language : From Beginners to Gophers
I.I.S. G. Vallauri - Fossano
 
Emerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the HorizonEmerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the Horizon
Alex Payne
 
r,rstats,r language,r packages
r,rstats,r language,r packagesr,rstats,r language,r packages
r,rstats,r language,r packages
Ajay Ohri
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
David Padbury
 
Clojure And Swing
Clojure And SwingClojure And Swing
Clojure And Swing
Skills Matter
 
20230721_OKC_Meetup_MuleSoft.pptx
20230721_OKC_Meetup_MuleSoft.pptx20230721_OKC_Meetup_MuleSoft.pptx
20230721_OKC_Meetup_MuleSoft.pptx
DianeKesler1
 
Things about Functional JavaScript
Things about Functional JavaScriptThings about Functional JavaScript
Things about Functional JavaScript
ChengHui Weng
 
JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter PilgrimJavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
JavaCro 2014 Scala and Java EE 7 Development Experiences
JavaCro 2014 Scala and Java EE 7 Development ExperiencesJavaCro 2014 Scala and Java EE 7 Development Experiences
JavaCro 2014 Scala and Java EE 7 Development Experiences
Peter Pilgrim
 
Presto anatomy
Presto anatomyPresto anatomy
Presto anatomy
Dongmin Yu
 
A brief introduction to PostgreSQL
A brief introduction to PostgreSQLA brief introduction to PostgreSQL
A brief introduction to PostgreSQL
Vu Hung Nguyen
 
Exploring Clojurescript
Exploring ClojurescriptExploring Clojurescript
Exploring Clojurescript
Luke Donnet
 
A Recovering Java Developer Learns to Go
A Recovering Java Developer Learns to GoA Recovering Java Developer Learns to Go
A Recovering Java Developer Learns to Go
Matt Stine
 
Talk - Query monad
Talk - Query monad Talk - Query monad
Talk - Query monad
Fabernovel
 
PofEAA and SQLAlchemy
PofEAA and SQLAlchemyPofEAA and SQLAlchemy
PofEAA and SQLAlchemy
Inada Naoki
 
Lobos Introduction
Lobos IntroductionLobos Introduction
Lobos Introduction
Nicolas Buduroi
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
Dmitry Buzdin
 
Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)
Jonathan Felch
 
Seattle useR Group - R + Scala
Seattle useR Group - R + ScalaSeattle useR Group - R + Scala
Seattle useR Group - R + Scala
Shouheng Yi
 
Pune Clojure Course Outline
Pune Clojure Course OutlinePune Clojure Course Outline
Pune Clojure Course Outline
Baishampayan Ghose
 
Emerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the HorizonEmerging Languages: A Tour of the Horizon
Emerging Languages: A Tour of the Horizon
Alex Payne
 
r,rstats,r language,r packages
r,rstats,r language,r packagesr,rstats,r language,r packages
r,rstats,r language,r packages
Ajay Ohri
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
David Padbury
 
Clojure And Swing
Clojure And SwingClojure And Swing
Clojure And Swing
Skills Matter
 
20230721_OKC_Meetup_MuleSoft.pptx
20230721_OKC_Meetup_MuleSoft.pptx20230721_OKC_Meetup_MuleSoft.pptx
20230721_OKC_Meetup_MuleSoft.pptx
DianeKesler1
 
Things about Functional JavaScript
Things about Functional JavaScriptThings about Functional JavaScript
Things about Functional JavaScript
ChengHui Weng
 
JavaCro 2014 Scala and Java EE 7 Development Experiences
JavaCro 2014 Scala and Java EE 7 Development ExperiencesJavaCro 2014 Scala and Java EE 7 Development Experiences
JavaCro 2014 Scala and Java EE 7 Development Experiences
Peter Pilgrim
 
Presto anatomy
Presto anatomyPresto anatomy
Presto anatomy
Dongmin Yu
 
A brief introduction to PostgreSQL
A brief introduction to PostgreSQLA brief introduction to PostgreSQL
A brief introduction to PostgreSQL
Vu Hung Nguyen
 
Exploring Clojurescript
Exploring ClojurescriptExploring Clojurescript
Exploring Clojurescript
Luke Donnet
 
Ad

More from Hermann Hueck (11)

A Taste of Dotty
A Taste of DottyA Taste of Dotty
A Taste of Dotty
Hermann Hueck
 
What's new in Scala 2.13?
What's new in Scala 2.13?What's new in Scala 2.13?
What's new in Scala 2.13?
Hermann Hueck
 
Pragmatic sbt
Pragmatic sbtPragmatic sbt
Pragmatic sbt
Hermann Hueck
 
Implementing the IO Monad in Scala
Implementing the IO Monad in ScalaImplementing the IO Monad in Scala
Implementing the IO Monad in Scala
Hermann Hueck
 
Future vs. Monix Task
Future vs. Monix TaskFuture vs. Monix Task
Future vs. Monix Task
Hermann Hueck
 
Use Applicative where applicable!
Use Applicative where applicable!Use Applicative where applicable!
Use Applicative where applicable!
Hermann Hueck
 
From Function1#apply to Kleisli
From Function1#apply to KleisliFrom Function1#apply to Kleisli
From Function1#apply to Kleisli
Hermann Hueck
 
Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)
Hermann Hueck
 
From Functor Composition to Monad Transformers
From Functor Composition to Monad TransformersFrom Functor Composition to Monad Transformers
From Functor Composition to Monad Transformers
Hermann Hueck
 
Type Classes in Scala and Haskell
Type Classes in Scala and HaskellType Classes in Scala and Haskell
Type Classes in Scala and Haskell
Hermann Hueck
 
Reactive Access to MongoDB from Java 8
Reactive Access to MongoDB from Java 8Reactive Access to MongoDB from Java 8
Reactive Access to MongoDB from Java 8
Hermann Hueck
 
A Taste of Dotty
A Taste of DottyA Taste of Dotty
A Taste of Dotty
Hermann Hueck
 
What's new in Scala 2.13?
What's new in Scala 2.13?What's new in Scala 2.13?
What's new in Scala 2.13?
Hermann Hueck
 
Implementing the IO Monad in Scala
Implementing the IO Monad in ScalaImplementing the IO Monad in Scala
Implementing the IO Monad in Scala
Hermann Hueck
 
Future vs. Monix Task
Future vs. Monix TaskFuture vs. Monix Task
Future vs. Monix Task
Hermann Hueck
 
Use Applicative where applicable!
Use Applicative where applicable!Use Applicative where applicable!
Use Applicative where applicable!
Hermann Hueck
 
From Function1#apply to Kleisli
From Function1#apply to KleisliFrom Function1#apply to Kleisli
From Function1#apply to Kleisli
Hermann Hueck
 
Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)Composing an App with Free Monads (using Cats)
Composing an App with Free Monads (using Cats)
Hermann Hueck
 
From Functor Composition to Monad Transformers
From Functor Composition to Monad TransformersFrom Functor Composition to Monad Transformers
From Functor Composition to Monad Transformers
Hermann Hueck
 
Type Classes in Scala and Haskell
Type Classes in Scala and HaskellType Classes in Scala and Haskell
Type Classes in Scala and Haskell
Hermann Hueck
 
Reactive Access to MongoDB from Java 8
Reactive Access to MongoDB from Java 8Reactive Access to MongoDB from Java 8
Reactive Access to MongoDB from Java 8
Hermann Hueck
 

Recently uploaded (20)

Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025
kashifyounis067
 
Kubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptxKubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptx
CloudScouts
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdfMicrosoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
TechSoup
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AIScaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
danshalev
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
Egor Kaleynik
 
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRYLEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
NidaFarooq10
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Dele Amefo
 
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Orangescrum
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
Not So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java WebinarNot So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java Webinar
Tier1 app
 
WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New VersionPixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
saimabibi60507
 
Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025
kashifyounis067
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025Adobe After Effects Crack FREE FRESH version 2025
Adobe After Effects Crack FREE FRESH version 2025
kashifyounis067
 
Kubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptxKubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptx
CloudScouts
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Proactive Vulnerability Detection in Source Code Using Graph Neural Networks:...
Ranjan Baisak
 
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdfMicrosoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
Microsoft AI Nonprofit Use Cases and Live Demo_2025.04.30.pdf
TechSoup
 
Societal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainabilitySocietal challenges of AI: biases, multilinguism and sustainability
Societal challenges of AI: biases, multilinguism and sustainability
Jordi Cabot
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AIScaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
danshalev
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
How Valletta helped healthcare SaaS to transform QA and compliance to grow wi...
Egor Kaleynik
 
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRYLEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
LEARN SEO AND INCREASE YOUR KNOWLDGE IN SOFTWARE INDUSTRY
NidaFarooq10
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Salesforce Data Cloud- Hyperscale data platform, built for Salesforce.
Dele Amefo
 
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Orangescrum
 
Exploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the FutureExploring Wayland: A Modern Display Server for the Future
Exploring Wayland: A Modern Display Server for the Future
ICS
 
Not So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java WebinarNot So Common Memory Leaks in Java Webinar
Not So Common Memory Leaks in Java Webinar
Tier1 app
 
WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New VersionPixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
saimabibi60507
 
Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025
kashifyounis067
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 

Implementing a many-to-many Relationship with Slick

  • 1. Implementing a many-to-many Relationship with Slick Implementing a many-to-many Relationship with Slick Author: Hermann Hueck Source code and Slides available at: https://github.com/hermannhueck/MusicService/tree/master/Services/MusicService-Play-Scala-Slick-NoAuth http://de.slideshare.net/hermannhueck/implementing-a-manytomany-relationship-with-slick
  • 2. Who am I?Who am I? Hermann Hueck Software Developer – Scala, Java, Akka, Play https://www.xing.com/profile/Hermann_Hueck
  • 3. Presentation OverviewPresentation Overview ● Short Intro to Slick ● Many-to-many Relationship with Slick – Example: A Music Service ● Q & A
  • 4. Part 1: Intro to SlickPart 1: Intro to Slick ● What is Slick? ● What is FRM (Functional Relational Mapping)? ● How to execute a database action? ● Why is it reactive? ● Short Reminder of Scala Futures ● Simple Slick Example (Activator Template: hello-slick-3.1) ● Table Definitions without and with Case Class Mapping
  • 5. What is Slick?What is Slick? The Slick manual says: Slick (“Scala Language-Integrated Connection Kit”) is Typesafe‘s Functional Relational Mapping (FRM) library for Scala that makes it easy to work with relational databases. It allows you to work with stored data almost as if you were using Scala collections while at the same time giving you full control over when a database access happens and which data is transferred. You can also use SQL directly. Execution of database actions is done asynchronously, making Slick a perfect fit for your reactive applications based on Play and Akka.
  • 6. What is FRM?What is FRM? ● FRM = Functional Relational Mapping (opposed to ORM) ● Slick allows you to process persistent relational data stored in DB tables the same (functional) way as you do with in-memory data, i.e. Scala collections. ● Table Queries are monads. ● Table Queries are pre-optimized. ● Table Queries are type-safe. ● The Scala compiler complains, if you specify your table query incorrectly.
  • 7. TableQuery s are Monads.TableQuery s are Monads. ● filter() for the selection of data ● map() for the projection ● flatMap() to pass the output of your 1st DB operation as input to the 2nd DB operation. ● With the provision of these three monadical functions TableQuery s are monads. ● Hence you can also use the syntactic sugar of for-comprehensions. ● There is more. E.g. the sortBy() function allows you to define the sort order of your query result.
  • 8. How to execute a Slick DB Action?How to execute a Slick DB Action? ● Define a TableQuery val query: Query[
] = TableQuery(
)
 ● For this TableQuery, define a database action which might be a query, insert, bulk insert, update or a delete action or even a DDL action. val dbAction: DBIO[
] = query += record // insert val dbAction: DBIO[
] = query ++= Seq(row0, row1, 
, rowN) // bulk insert val dbAction: DBIO[
] = query.update(valuesToUpdate) // update val dbAction: DBIO[
] = query.delete // delete val dbAction: DBIO[
] = query.result // insert ● Run the database action by calling db.run(dbAction). db.run never returns the Result. You always get a Future[Result]. val dbAction: DBIO[
] = TableQuery(
).result val future: Future[
] = db.run(dbAction)
  • 9. Why is Slick reactive?Why is Slick reactive? ● It is asynchronous and non-blocking. ● It provides its own configurable thread pool. ● If you run a database action you never get the Result directly. You always get a Future[Result]. val dbAction: DBIOAction[Seq[String]] = TableQuery(
).result val future: Future[Seq[String]] = db.run( dbAction ) ● Slick supports Reactive Streams. Hence it can easily be used together with Akka-Streams (which is not subject of this talk). val dbAction: StreamingDBIO[Seq[String]] = TableQuery(
).result val publisher: DatabasePublisher[String] = db.stream( dbAction ) val source: Source = Source.fromPublisher( publisher ) // Now use the Source to construct a RunnableGraph. Then run the graph.
  • 10. Short Reminder of Scala FuturesShort Reminder of Scala Futures In Slick every database access returns a Future. How can one async (DB) function process the result of another async (DB) function? This scenario happens very often when querying and manipulating database records. A very informative and understandable blog on Futures can be found here: http://danielwestheide.com/blog/2013/01/09/the-neophytes-guide-to-scala -part-8-welcome-to-the-future.html
  • 11. How to process the Result of an Async Function by another Async Function How to process the Result of an Async Function by another Async Function Using Future.flatMap: def doAAsync(input: String): Future[A] = Future { val a = f(input); a } def doBAsync(a: A): Future[B] = Future { val b = g(a); b } val input = “some input“ val futureA: Future[A] = doAAsync(input) val futureB: Future[B] = futureA flatMap { a => doBAsync(a) } futureB.foreach { b => println(b) }
  • 12. Async Function processing the Result of another Async Function Async Function processing the Result of another Async Function Using a for-comprehension: def doAAsync(input: String): Future[A] = Future { val a = f(input); a } def doBAsync(a: A): Future[B] = Future { val b = g(a); b } val input = “some input“ val futureB: Future[B] = for { a <- doAAsync(input) b <- doBAsync(a) } yield b futureB.foreach { b => println(b) }
  • 13. A Simple Slick ExampleA Simple Slick Example Activator Template: hello-slick-3.1
  • 14. Table Definition with a TupleTable Definition with a Tuple class Users(tag: Tag) extends Table[(String, Option[Int])](tag, "USERS") { // Auto Increment the id primary key column def id = column[Int]("ID", O.PrimaryKey, O.AutoInc) // The name can't be null def name = column[String]("NAME", O.NotNull) // the * projection (e.g. select * ...) def * = (name, id.?) } Tuple
  • 15. Table Definition with Case Class Mapping Table Definition with Case Class Mapping case class User(name: String, id: Option[Int] = None) class Users(tag: Tag) extends Table[User](tag, "USERS") { // Auto Increment the id primary key column def id = column[Int]("ID", O.PrimaryKey, O.AutoInc) // The name can't be null def name = column[String]("NAME", O.NotNull) // the * projection (e.g. select * ...) auto-transforms the tupled // column values to / from a User def * = (name, id.?) <> (User.tupled, User.unapply) } Map Tuple to User Map User to Tuple
  • 16. Part 2: Many-to-many with SlickPart 2: Many-to-many with Slick ● The Demo App: MusicService ● Many-to-many Relationship (DB Schema) ● Web Application Demo ● Many-to-many in Slick Table Definitions ● Ensuring Referential Integrity ● Adding and Deleting Relationships ● Traversing the many-to-many Relationship in Queries
  • 17. The Demo App: MusicServiceThe Demo App: MusicService ● The MusicService manages Music Recordings and Performers. ● A Recording is performedBy many (0 
 n) Performers. ● A Performer is performingIn many (0 
 n) Recordings.
  • 18. Many-to-many in the DB SchemaMany-to-many in the DB Schema ID NAME PERFORMER_TYPE 1 Arthur Rubinstein Soloist 2 London Phil. Orch. Ensemble 3 Herbert von Karajan Conductor 4 Christopher Park Soloist ... PERFORMERS ID TITLE COMPOSER YEAR 1 Beethoven's Symphony No. 5 Ludwig v. Beethoven 2005 2 Forellenquintett Franz Schubert 2006 3 Eine kleine Nachtmusik Wolfgang Amadeus Mozart 2005 4 EntfĂŒhrung aus dem Serail Wolfgang Amadeus Mozart 2008 ... RECORDINGS REC_ID PER_ID 1 1 1 2 1 3 3 1 ... ... RECORDINGS_PERFORMERS
  • 19. Web Application DemoWeb Application Demo MusicService is a Play Application with a rather primitive UI. This interface allows the user to 
 ● Create, delete, update Performers and Recordings ● Assign Performers to Recordings or Recordings to Performers and delete these Assignments ● Query / Search for Performers and Recordings ● Play Recordings
  • 20. Many-to-many Relationship in the Slick Table Definitions Many-to-many Relationship in the Slick Table Definitions case class RecordingPerformer(recId: Long, perId: Long) // Table 'RecordingsPerformers' mapped to case class 'RecordingPerformer' as join table to map // the many-to-many relationship between Performers and Recordings // class RecordingsPerformers(tag: Tag) extends Table[RecordingPerformer](tag, "RECORDINGS_PERFORMERS") { def recId: Rep[Long] = column[Long]("REC_ID") def perId: Rep[Long] = column[Long]("PER_ID") def * = (recId, perId) <> (RecordingPerformer.tupled, RecordingPerformer.unapply) def pk = primaryKey("primaryKey", (recId, perId)) def recFK = foreignKey("FK_RECORDINGS", recId, TableQuery[Recordings])(recording => recording.id, onDelete=ForeignKeyAction.Cascade) def perFK = foreignKey("FK_PERFORMERS", perId, TableQuery[Performers])(performer => performer.id) // onUpdate=ForeignKeyAction.Restrict is omitted as this is the default }
  • 21. Ensuring Referential IntegrityEnsuring Referential Integrity ● Referential Integrity is guaranteed by the definition of a foreignKey() function in the referring table, which allows to navigate to the referred table. ● You can optionally specify an onDelete action and an onUpdate action, which has one of the following values:  ForeignKeyAction.NoAction  ForeignKeyAction.Restrict  ForeignKeyAction.Cascade  ForeignKeyAction.SetNull  ForeignKeyAction.SetDefault
  • 22. Adding and Deleting RelationshipsAdding and Deleting Relationships ● Adding a concrete relationship == Adding an entry into the Mapping Table, if it doesn't already exist. ● Deleting a concrete relationship == Deleting an entry from the Mapping Table, if it exists. ● Updates in the Mapping Table do not make much sense. Hence I do not support them im my implementation.
  • 23. Traversing many-to-many the Relationship in Queries Traversing many-to-many the Relationship in Queries ● The Query.join() function allows you to perform an inner join on tables. ● The Query.on() function allows you to perform an inner join on tables. ● Example: val query = TableQuery[Performers] join TableQuery[RecordingsPerformers] on (_.id === _.perId) val future: Future[Seq[(Performer, RecordingPerformer)]] = db.run { query.result } // Now postprocess this future with filter, map, flatMap etc. // Especially filter the result for a specific recording id.
  • 24. Thank you for listening!
  • 25. Q & A
  • 26. ResourcesResources ● Slick Website: http://slick.typesafe.com/doc/3.1.1/ ● Slick Activator Template Website with Tutorial: https://www.typesafe.com/activator/template/hello-slick-3.1 ● Slick Activator Template Source Code: https://github.com/typesafehub/activator-hello-slick#slick-3.1 ● A very informative blog on Futures: http://danielwestheide.com/blog/2013/01/09/the-neophytes-guide-to-scala-part-8-welcome-to-the- future.html ● MusicService Source Code and Slides at Github: https://github.com/hermannhueck/MusicService/tree/master/Services/MusicService-Play-Scala-S lick-NoAuth ● MusicService Slides at SlideShare: http://de.slideshare.net/hermannhueck/implementing-a-manytomany-relationship-with-slick ● Authors XING Profile: https://www.xing.com/profile/Hermann_Hueck