SlideShare uma empresa Scribd logo
1 de 93
Baixar para ler offline
Datomic
Lidando com dados de maneira versionada
Rodrigo Flores
@rlmflores
rodrigo.flores@nubank.com.br
Luiz Hespanha
@luiz_hespanha
luiz.hespanha@nubank.com.br
Datomic
Arquitetura
ACID
Funções
Dados em uma estrutura financeira
Datomic
Banco Orientado a Fatos
ID Nome Telefone Celular Telefone Fixo
1 John Doe 11 5555 5555 11 5556 5556
2 Mark Doe 11 5555 5556 NULL
3 Jane Doe 11 5555 6666 NULL
Modelo Entidade-Atributo-Valor (EAV)
ID Atributo Valor
1 Nome John Doe
1 Telefone Celular 11 5555 5555
1 Telefone Fixo 11 5556 5556
2 Nome Mark Doe
2 Telefone Celular 11 5555 5556
3 Nome Jane Doe
3 Telefone Celular 11 5555 6666
Modelo EAVT - Datomic
ID Atributo Valor Transação
1 Nome John Doe 12
1 Telefone Celular 11 5555 5555 12
1 Telefone Fixo 11 5556 5556 13
2 Nome Mary Poppins 25
2 Telefone Celular 11 5555 5556 67
2 Recomendado
por
1 128
3 Nome Jane Doe 222
3 Telefone Celular 11 5555 6666 223
Fatos podem deixar de ser fatos
ID Atributo Valor Transação
1 Telefone Fixo 11 5555 5555 12
1 Telefone Fixo 11 5555 5555 55
É possível sobrescrever um fato
ID Atributo Valor Transação
1 Nome Jane Doe 25
1 Nome Jane Doe 98
1 Nome Jane Mary Doe 98
Mas isso é uma sobrescrita
Transações do banco de dados são
entidades
ID Atributo Valor Transação
1 Nome John Doe 12
1 Telefone Celular 11 5555 5555 12
1 Telefone Fixo 11 5556 5556 13
2 Nome Mary Poppins 25
2 Telefone Celular 11 5555 5556 67
3 Nome Jane Doe 72
3 Telefone Celular 11 5555 6666 99
ID Atributo Valor
12 Hora 2012-09-12T00:00:00Z
13 Hora 2012-09-12T00:00:05Z
25 Hora 2012-09-22T00:00:00Z
Qualquer informação relevante pode
ser adicionada na transação
ID Atributo Valor
12 Hora 2012-09-12T00:00:00Z
12 Usuário Joaquim José
13 Hora 2012-09-12T00:00:05Z
13 Usuário Maria Augusta
Arquivos em um controle de versão
Arquivos em uma pasta
vs
Queries
Programação Lógica
[[?entidade :atributo1 ?valor1]]

{:find [?celular]

:in [?nome]

:where [[?pessoa :pessoa/nome ?nome]

[?pessoa :pessoa/telefone-celular ?
celular]]}

{:find [?nome]

:where [[?pessoa :pessoa/nome ?nome]

[?pessoa :pessoa/idade ?idade]

[(> ?idade 35)]]}
Schema
Todo atributo tem um tipo
Integer String
Long Boolean
Double UUID
Big Int Ref
Big Dec Instant
Float
Sempre não nulo
Não há obrigatoriedade de campo
Viajando no tempo
Default
ID Atributo Valor Hora da Transação
1 Nome Jane Doe 25/03/2015 10:00:12Z
1 CPF 11111111111 25/03/2015 10:00:12Z
1 Telefone 11 5555 5555 25/03/2015 10:00:12Z
1 Nome Jane Doe 12/04/2015 15:02:27Z
1 Nome Jane Mary Doe 12/04/2015 15:02:27Z
As Of
ID Atributo Valor Hora da Transação
1 Nome Jane Doe 25/03/2015 10:00:12Z
1 CPF 11111111111 25/03/2015 10:00:12Z
1 Telefone 11 5555 5555 25/03/2015 10:00:12Z
1 Nome Jane Doe 12/04/2015 15:02:27Z
1 Nome Jane Mary Doe 12/04/2015 15:02:27Z
Qual era o telefone da cliente cujo CPF é “11111111111” no instante
2015-05-08T01:12:00Z ?
ID Atributo Valor Hora da Transação
1 Nome Jane Doe 25/03/2015 10:00:12Z
1 CPF 11111111111 25/03/2015 10:00:12Z
1 Telefone 11 5555 5555 25/03/2015 10:00:12Z
1 Nome Jane Doe 12/04/2015 15:02:27Z
1 Nome Jane Mary Doe 12/04/2015 15:02:27Z
Qual o nome do cliente cujo CPF é “11111111111” no instante
2015-04-01T01:12:00Z ?
ID Atributo Valor Hora da Transação
1 Nome Jane Doe 25/03/2015 10:00:12Z
1 CPF 11111111111 25/03/2015 10:00:12Z
1 Telefone 11 5555 5555 25/03/2015 10:00:12Z
1 Nome Jane Doe 12/04/2015 15:02:27Z
1 Nome Jane Mary Doe 12/04/2015 15:02:27Z
Since
ID Atributo Valor Hora da Transação
1 Nome Jane Doe 25/03/2015 10:00:12Z
1 CPF 11111111111 25/03/2015 10:00:12Z
1 Telefone 11 5555 5555 25/03/2015 10:00:12Z
1 Nome Jane Doe 12/04/2015 15:02:27Z
1 Nome Jane Mary Doe 12/04/2015 15:02:27Z
Quais foram os clientes que mudaram de nome após dia 01/04 ?
ID Atributo Valor Hora da Transação
1 Nome Jane Doe 25/03/2015 10:00:12Z
1 CPF 11111111111 25/03/2015 10:00:12Z
1 Telefone 11 5555 5555 25/03/2015 10:00:12Z
1 Nome Jane Doe 12/04/2015 15:02:27Z
1 Nome Jane Mary Doe 12/04/2015 15:02:27Z
History
ID Atributo Valor Hora da Transação
1 Nome Jane Doe 25/03/2015 10:00:12Z
1 CPF 11111111111 25/03/2015 10:00:12Z
1 Telefone 11 5555 5555 25/03/2015 10:00:12Z
1 Nome Jane Doe 12/04/2015 15:02:27Z
1 Nome Jane Mary Doe 12/04/2015 15:02:27Z
Qual foram todos os nomes utilizados pelo cliente cujo CPF
é 11111111111 ?
ID Atributo Valor Hora da Transação
1 Nome Jane Doe 25/03/2015 10:00:12Z
1 CPF 11111111111 25/03/2015 10:00:12Z
1 Telefone 11 5555 5555 25/03/2015 10:00:12Z
1 Nome Jane Doe 12/04/2015 15:02:27Z
1 Nome Jane Mary Doe 12/04/2015 15:02:27Z
Qual era o nome do cliente cujo nome hoje é Jane Mary Doe no dia
01/04/2015 ?
Múltiplos bancos
(d/query {:find [?as-of-nome]

:in [$current-db $as-of-db]

:where [[$current-db ?pessoa :pessoa/
nome "Jane Mary Doe"]

[$old-db ?pessoa :pessoa/nome ?
as-of-nome]]}

(d/db connection)

(d/as-of #inst "2015-04-01T00:00:00Z"))
Banco orientado a fatos
Fatos não são “apagados” ou alterados: escrevemos novos
valores como novas “versões" de fatos antigos
Pode-se buscar no banco com uma data específica, com
fatos inseridos a partir de uma certa data, ou em todo o
histórico
Pode-se utilizar mais de um banco em uma query;
Arquitetura
Imagem retirada de http://docs.datomic.com/architecture.html
Serviço de "storage"
Peers
Processo que manipula o banco usando a biblioteca “Datomi
Peer"
API para Clojure e Java
Cada Peer possui um cache com o serviço de Storage
Qualquer processo pode ser um Peer
• Web Server
• Aplicação GUI
• Aplicação de linha de comando
Mas eu não uso uma linguagem JVM-Hosted, e agora?
REST API
Um PEER pode ser iniciado como um serviço HTTP
standalone.
Transactor
Responsável por toda escrita no banco de dados
Notifica todos os PEERS sobre novos fatos.
E quando o Datomic não é uma boa escolha ?
ACID
Atômico
Transação
Ou faz tudo, ou aborta
Consistente
Validação de tipos e NULL
Transações só são vistas por
completo
Isolamento
Uma escrita por vez
Durável
Só dá o OK depois de escrever no storage
ACID
Funções com regras de negócio
Funções a nível de transação.
Escopo limitado / Banco filtrado
Excision - Apagar dados de maneira definitiva
Conclusão
Dados são importantes
Auditoria de informação
Bancos históricos
Facilidade de deploy
OBRIGADO!
Estamos contratando!
http://bit.ly/trabalhe-na-nubank

Mais conteúdo relacionado

Mais procurados

Time de UX do PicPay
Time de UX do PicPayTime de UX do PicPay
Time de UX do PicPayMergo
 
Enterprise Risk Management and Business Continuity: How Can They Work Togethe...
Enterprise Risk Management and Business Continuity: How Can They Work Togethe...Enterprise Risk Management and Business Continuity: How Can They Work Togethe...
Enterprise Risk Management and Business Continuity: How Can They Work Togethe...BCM Institute
 
MLOps Virtual Event | Building Machine Learning Platforms for the Full Lifecycle
MLOps Virtual Event | Building Machine Learning Platforms for the Full LifecycleMLOps Virtual Event | Building Machine Learning Platforms for the Full Lifecycle
MLOps Virtual Event | Building Machine Learning Platforms for the Full LifecycleDatabricks
 
EY: Why graph technology makes sense for fraud detection and customer 360 pro...
EY: Why graph technology makes sense for fraud detection and customer 360 pro...EY: Why graph technology makes sense for fraud detection and customer 360 pro...
EY: Why graph technology makes sense for fraud detection and customer 360 pro...Neo4j
 
Plano de Mídias - Red Bull Brasil
Plano de  Mídias - Red Bull Brasil Plano de  Mídias - Red Bull Brasil
Plano de Mídias - Red Bull Brasil AnaBeatrizZaccaria
 
Mobilize Breakfast- Apresentação Rock in Rio
Mobilize Breakfast- Apresentação Rock in RioMobilize Breakfast- Apresentação Rock in Rio
Mobilize Breakfast- Apresentação Rock in RioPontomobi
 
How to Build a ML Platform Efficiently Using Open-Source
How to Build a ML Platform Efficiently Using Open-SourceHow to Build a ML Platform Efficiently Using Open-Source
How to Build a ML Platform Efficiently Using Open-SourceDatabricks
 
Digital transformation sweet spot: Business operations
Digital transformation sweet spot: Business operationsDigital transformation sweet spot: Business operations
Digital transformation sweet spot: Business operationsMarcel Santilli
 
Thabo Ndlela- Leveraging AI for enhanced Customer Service and Experience
Thabo Ndlela- Leveraging AI for enhanced Customer Service and ExperienceThabo Ndlela- Leveraging AI for enhanced Customer Service and Experience
Thabo Ndlela- Leveraging AI for enhanced Customer Service and Experienceitnewsafrica
 
Generative AI_ The force-multiplier for SDLC.pptx
Generative AI_ The force-multiplier for SDLC.pptxGenerative AI_ The force-multiplier for SDLC.pptx
Generative AI_ The force-multiplier for SDLC.pptxKumar Iyer
 
Building and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache AirflowBuilding and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache AirflowKaxil Naik
 
Productionizing Real-time Serving With MLflow
Productionizing Real-time Serving With MLflowProductionizing Real-time Serving With MLflow
Productionizing Real-time Serving With MLflowDatabricks
 
Investor presentation may_2013_-_external_v2
Investor presentation may_2013_-_external_v2Investor presentation may_2013_-_external_v2
Investor presentation may_2013_-_external_v2John Shay
 
Chief AI Officer and AI Digital Transformation
Chief AI Officer and AI Digital TransformationChief AI Officer and AI Digital Transformation
Chief AI Officer and AI Digital TransformationValue Amplify Consulting
 
Digital Transformation Services- Our Corporate Brochure
Digital Transformation Services- Our Corporate BrochureDigital Transformation Services- Our Corporate Brochure
Digital Transformation Services- Our Corporate BrochureNeuronimbus Software Services
 

Mais procurados (20)

Time de UX do PicPay
Time de UX do PicPayTime de UX do PicPay
Time de UX do PicPay
 
Enterprise Risk Management and Business Continuity: How Can They Work Togethe...
Enterprise Risk Management and Business Continuity: How Can They Work Togethe...Enterprise Risk Management and Business Continuity: How Can They Work Togethe...
Enterprise Risk Management and Business Continuity: How Can They Work Togethe...
 
Case NuBank
Case NuBankCase NuBank
Case NuBank
 
MLOps Virtual Event | Building Machine Learning Platforms for the Full Lifecycle
MLOps Virtual Event | Building Machine Learning Platforms for the Full LifecycleMLOps Virtual Event | Building Machine Learning Platforms for the Full Lifecycle
MLOps Virtual Event | Building Machine Learning Platforms for the Full Lifecycle
 
EY: Why graph technology makes sense for fraud detection and customer 360 pro...
EY: Why graph technology makes sense for fraud detection and customer 360 pro...EY: Why graph technology makes sense for fraud detection and customer 360 pro...
EY: Why graph technology makes sense for fraud detection and customer 360 pro...
 
Plano de Mídias - Red Bull Brasil
Plano de  Mídias - Red Bull Brasil Plano de  Mídias - Red Bull Brasil
Plano de Mídias - Red Bull Brasil
 
Josh Cavalier - ChatGPT Prompt Strategies.pdf
Josh Cavalier - ChatGPT Prompt Strategies.pdfJosh Cavalier - ChatGPT Prompt Strategies.pdf
Josh Cavalier - ChatGPT Prompt Strategies.pdf
 
Mobilize Breakfast- Apresentação Rock in Rio
Mobilize Breakfast- Apresentação Rock in RioMobilize Breakfast- Apresentação Rock in Rio
Mobilize Breakfast- Apresentação Rock in Rio
 
Relatório de performance para Social Media
Relatório de performance para Social MediaRelatório de performance para Social Media
Relatório de performance para Social Media
 
How to Build a ML Platform Efficiently Using Open-Source
How to Build a ML Platform Efficiently Using Open-SourceHow to Build a ML Platform Efficiently Using Open-Source
How to Build a ML Platform Efficiently Using Open-Source
 
Digital transformation sweet spot: Business operations
Digital transformation sweet spot: Business operationsDigital transformation sweet spot: Business operations
Digital transformation sweet spot: Business operations
 
Thabo Ndlela- Leveraging AI for enhanced Customer Service and Experience
Thabo Ndlela- Leveraging AI for enhanced Customer Service and ExperienceThabo Ndlela- Leveraging AI for enhanced Customer Service and Experience
Thabo Ndlela- Leveraging AI for enhanced Customer Service and Experience
 
Generative AI_ The force-multiplier for SDLC.pptx
Generative AI_ The force-multiplier for SDLC.pptxGenerative AI_ The force-multiplier for SDLC.pptx
Generative AI_ The force-multiplier for SDLC.pptx
 
State of the Cloud 2023—The AI era
State of the Cloud 2023—The AI eraState of the Cloud 2023—The AI era
State of the Cloud 2023—The AI era
 
Pitch Deck V2
Pitch Deck V2Pitch Deck V2
Pitch Deck V2
 
Building and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache AirflowBuilding and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache Airflow
 
Productionizing Real-time Serving With MLflow
Productionizing Real-time Serving With MLflowProductionizing Real-time Serving With MLflow
Productionizing Real-time Serving With MLflow
 
Investor presentation may_2013_-_external_v2
Investor presentation may_2013_-_external_v2Investor presentation may_2013_-_external_v2
Investor presentation may_2013_-_external_v2
 
Chief AI Officer and AI Digital Transformation
Chief AI Officer and AI Digital TransformationChief AI Officer and AI Digital Transformation
Chief AI Officer and AI Digital Transformation
 
Digital Transformation Services- Our Corporate Brochure
Digital Transformation Services- Our Corporate BrochureDigital Transformation Services- Our Corporate Brochure
Digital Transformation Services- Our Corporate Brochure
 

Destaque

Trabalhando com Threads em JAVA
Trabalhando com Threads em JAVATrabalhando com Threads em JAVA
Trabalhando com Threads em JAVAMarcio Palheta
 
Testes em uma startup do mundo financeiro
Testes em uma startup do mundo financeiroTestes em uma startup do mundo financeiro
Testes em uma startup do mundo financeiroLuiz Alberto Hespanha
 
Clojure No Mundo Real
Clojure No Mundo RealClojure No Mundo Real
Clojure No Mundo RealiMasters
 
Decreto regulamentar 2 de 2010 avaliação de desempenho
Decreto regulamentar 2 de 2010 avaliação de desempenhoDecreto regulamentar 2 de 2010 avaliação de desempenho
Decreto regulamentar 2 de 2010 avaliação de desempenhoMaria João Vasconcelos
 
8 things I like about Datomic
8 things I like about Datomic8 things I like about Datomic
8 things I like about Datomicdatablend
 
The power of datomic
The power of datomicThe power of datomic
The power of datomicKonrad Szydlo
 
Apostila de Java: Orientação a Objetos
Apostila de Java: Orientação a ObjetosApostila de Java: Orientação a Objetos
Apostila de Java: Orientação a ObjetosK19 Treinamentos
 
DevOps: The IT Revolution Era
DevOps: The IT Revolution EraDevOps: The IT Revolution Era
DevOps: The IT Revolution EraDiego Pacheco
 
MSA: Quando a gestão encontra a arquitetura
MSA: Quando a gestão encontra a arquiteturaMSA: Quando a gestão encontra a arquitetura
MSA: Quando a gestão encontra a arquiteturaDiego Pacheco
 
Coaching & desenvolvimento de times
Coaching & desenvolvimento de timesCoaching & desenvolvimento de times
Coaching & desenvolvimento de timesDiego Pacheco
 
Microservices, soa e o melhor das filas
Microservices, soa e o melhor das filasMicroservices, soa e o melhor das filas
Microservices, soa e o melhor das filasDiego Pacheco
 
Datomic – A Modern Database - StampedeCon 2014
Datomic – A Modern Database - StampedeCon 2014Datomic – A Modern Database - StampedeCon 2014
Datomic – A Modern Database - StampedeCon 2014StampedeCon
 
Microservices reativos usando a stack do Netflix na AWS
Microservices reativos usando a stack do Netflix na AWSMicroservices reativos usando a stack do Netflix na AWS
Microservices reativos usando a stack do Netflix na AWSDiego Pacheco
 
Cloud Native, Microservices and SRE/Chaos Engineering: The new Rules of The G...
Cloud Native, Microservices and SRE/Chaos Engineering: The new Rules of The G...Cloud Native, Microservices and SRE/Chaos Engineering: The new Rules of The G...
Cloud Native, Microservices and SRE/Chaos Engineering: The new Rules of The G...Diego Pacheco
 
Quaderno degli esercizi - Nuovo progetto italiano 1
Quaderno degli esercizi - Nuovo progetto italiano 1Quaderno degli esercizi - Nuovo progetto italiano 1
Quaderno degli esercizi - Nuovo progetto italiano 1Silvi M
 

Destaque (20)

Testes generativos
Testes generativosTestes generativos
Testes generativos
 
Trabalhando com Threads em JAVA
Trabalhando com Threads em JAVATrabalhando com Threads em JAVA
Trabalhando com Threads em JAVA
 
Testes em uma startup do mundo financeiro
Testes em uma startup do mundo financeiroTestes em uma startup do mundo financeiro
Testes em uma startup do mundo financeiro
 
Clojure presentation
Clojure presentationClojure presentation
Clojure presentation
 
Clojure No Mundo Real
Clojure No Mundo RealClojure No Mundo Real
Clojure No Mundo Real
 
Decreto regulamentar 2 de 2010 avaliação de desempenho
Decreto regulamentar 2 de 2010 avaliação de desempenhoDecreto regulamentar 2 de 2010 avaliação de desempenho
Decreto regulamentar 2 de 2010 avaliação de desempenho
 
8 things I like about Datomic
8 things I like about Datomic8 things I like about Datomic
8 things I like about Datomic
 
The power of datomic
The power of datomicThe power of datomic
The power of datomic
 
Apostila de Java: Orientação a Objetos
Apostila de Java: Orientação a ObjetosApostila de Java: Orientação a Objetos
Apostila de Java: Orientação a Objetos
 
DevOps: The IT Revolution Era
DevOps: The IT Revolution EraDevOps: The IT Revolution Era
DevOps: The IT Revolution Era
 
MSA: Quando a gestão encontra a arquitetura
MSA: Quando a gestão encontra a arquiteturaMSA: Quando a gestão encontra a arquitetura
MSA: Quando a gestão encontra a arquitetura
 
Coaching & desenvolvimento de times
Coaching & desenvolvimento de timesCoaching & desenvolvimento de times
Coaching & desenvolvimento de times
 
Microservices, soa e o melhor das filas
Microservices, soa e o melhor das filasMicroservices, soa e o melhor das filas
Microservices, soa e o melhor das filas
 
Datomic – A Modern Database - StampedeCon 2014
Datomic – A Modern Database - StampedeCon 2014Datomic – A Modern Database - StampedeCon 2014
Datomic – A Modern Database - StampedeCon 2014
 
Dev opsdaykeynote
Dev opsdaykeynoteDev opsdaykeynote
Dev opsdaykeynote
 
Microservices reativos usando a stack do Netflix na AWS
Microservices reativos usando a stack do Netflix na AWSMicroservices reativos usando a stack do Netflix na AWS
Microservices reativos usando a stack do Netflix na AWS
 
Cloud Native, Microservices and SRE/Chaos Engineering: The new Rules of The G...
Cloud Native, Microservices and SRE/Chaos Engineering: The new Rules of The G...Cloud Native, Microservices and SRE/Chaos Engineering: The new Rules of The G...
Cloud Native, Microservices and SRE/Chaos Engineering: The new Rules of The G...
 
Quaderno degli esercizi - Nuovo progetto italiano 1
Quaderno degli esercizi - Nuovo progetto italiano 1Quaderno degli esercizi - Nuovo progetto italiano 1
Quaderno degli esercizi - Nuovo progetto italiano 1
 
Microservices
MicroservicesMicroservices
Microservices
 
Microservices in Clojure
Microservices in ClojureMicroservices in Clojure
Microservices in Clojure
 

Datomic - Lidando com dados de maneira versionada