$whoami
Loic Rollus - "Software developer"
Currently: "Guardis (IT infrastructure - ComodIT.com)"
Previously: "GIGA ULg (Cytomine team)"
Web site: "http://loic.rollus.be"
Linkedin: "https://be.linkedin.com/in/loicrollus"
Geeks Anonymes (2013):
"Software Quality and Continous Integration with Cytomine"
Belgium (1997)
Id (num) | Name (str) | Alcohol (dbl) | Brand (num) |
---|---|---|---|
16 (P.K.) | Chimay Bleue | 9.0 | 36 (F.K.) |
... | ... | ... | ... |
Id | Name | Location |
---|---|---|
36 | Chimay | Scourmont |
... | ... | ... |
Schema, Normalization, Constraints
Transactional ACID
BEGIN TRANSACTION
UPDATE account set amount = amount + 500 WHERE username = 'lrollus';
UPDATE account set amount = amount - 500 WHERE username = 'jfays';
END;
Robustness, Consistency
Users requests / dataset size
More ram, upgrade, more disk...
Users requests / dataset size
...arggggggg!
NoSQL: without SQL?
Non-relational: without relational model!
VS
Most of them are:
"16" = "Chimay Bleue"
Jedis jedis = new Jedis("localhost", 6379);
jedis.set("mykey", "Hello");
String value = jedis.get("mykey");
//auth
redis.set(token,username)
//req
username = redis.get(token)
hset(token,"username",username)
hset(token,"validity","2017-02-22")
expire(token,7*24*60*60)
N=3, W=2, R=2
row = document (json, xml,...)
{ id: 16, name: "Chimay Bleue",
brand: {name: "Chimay"}, alcohol: 9 }
Complex join on multiple nodes
Aggregate (Domain driven design)
Collection of related objects that we wish to treat as a unit
{
id: 16,
name: "Golf 2",
brand: {id: 2, name: "VW"},
engine: {name: "136-150 hp 2.0 16V", configuration: "1,984 cc"},
assembly: ["Wolfsburg", "Brussels"],
...
}
source: neo4j.com
If customer1 bought same beers as customer2, recommend customer2 beers to customer1.
CREATE (rm:Customer{username:'rmaree'})
CREATE (rh:Customer{username:'rhoyoux'})
CREATE (jf:Customer{username:'jfays'})
...
CREATE (o:Beer{name:'Orval'})
...
CREATE (rm)-[:BOUGHT ]->(cb)
CREATE (rm)-[:BOUGHT ]->(vt)
CREATE (rh)-[:BOUGHT ]->(o)
CREATE (rh)-[:BOUGHT ]->(vb)
CREATE (rh)-[:BOUGHT ]->(vt)
...
match
(c1:Customer)-[:BOUGHT]->(beer1:Beer)
<-[:BOUGHT]-(c2:Customer)-[:BOUGHT]->(beer2:Beer)
where not (c1)-[:BOUGHT]->(beer2)
return ...
match
(c1:Customer)-[:BOUGHT]->(beer1:Beer)
<-[:BOUGHT]-(c2:Customer)-[:BOUGHT]->(beer2:Beer)
where not (c1)-[:BOUGHT]->(beer2)
return c1.username as FirstPerson, c2.username as SecondPerson, beer1.name as
CommonProduct, beer2.name as RecommendedProduct;
match (c1:Customer)-[:BOUGHT]->(beer1:Beer)
<-[:BOUGHT]-(c2:Customer)-[:BOUGHT]->(beer2:Beer)
with c1,c2,count(beer1) as NrOfSharedProducts, collect(beer1) as
SharedProducts,beer2
where not (c1)-[:BOUGHT]->(beer2) AND NrOfSharedProducts >= 2
return ...
match (c1:Customer)-[:BOUGHT]->(beer1:Beer)
<-[:BOUGHT]-(c2:Customer)-[:BOUGHT]->(beer2:Beer)
with c1,c2,count(beer1) as NrOfSharedProducts, collect(beer1) as
SharedProducts,beer2
where not (c1)-[:BOUGHT]->(beer2) AND NrOfSharedProducts >= 2
return c1.username as FirPer, c2.username as SecPer, extract(x
in SharedProds | x.name) as SharedProds, beer2.name as RecomProd;
source: neo4j.com
Excessive (for the talk): take the best database(s)
GOTO Microservices...
https://www.martinfowler.com/
SQL VS NoSQL: Polyglot Persistence
3 NoSQL Admins walk into a bar...
...but they couldn't join a table.