SlideShare a Scribd company logo
Oracle Database Group
Oracle Database 23ai
Andres Almiray
Senior Principal Product Manager
Database Group
March 2025
Going Beyond ORMS
Andres Almiray
Senior Principal Product Manager
2
Copyright © 2024, Oracle and/or its affiliates
Relational: The good and the bad
Documents (JSON): The good and the bad
Can we combine the good from both?
JSON Relational Duality Views
Demo
Agenda
3
Going beyond ORMs with JSON Relational Duality Views
Oracle Converged Database
Blockchain tables
In-Database Machine Learning
Spatial
Relational
Columnar analytics
Property Graph/RDF
Native Binary JSON/XML
Text Data
Transactional Event Queue
Vector embeddings
Internet of Things
External Data
Copyright © 2024, Oracle and/or its affiliates
Oracle Converged Database
6
REST/GraphQL
APEX
Programming Languages
Java, Python, JavaScript, .Net, PL/SQL, C/C++, etc.
SQLcl/SQL Developer
Copyright © 2024, Oracle and/or its affiliates
Simple Example: Conference
7
Session
Attendee Speaker
Entities
Copyright © 2024, Oracle and/or its affiliates
Simple Example: Conference
8
Session
Attendee Speaker
Relationships, Cardinalities
N 1
N M
Copyright © 2024, Oracle and/or its affiliates
Simple Example: Conference, RELATIONAL
9
Session
Attendee Speaker
Tables
N 1
N M
ATTENDEE
AID NAME
A1 Jill
A2 Sanjay
SESSION
SID NAME ROOM SPID
S1 JSON OSLO SP1
S2 SQL TOKYO SP2
SPEAKER
SPID NAME PHONE
SP1 Carla 650..
SP2 Pascal 408...
ATT_SES_MAP
AID SID
A1 S1
A2 S2
Copyright © 2024, Oracle and/or its affiliates
Simple Example: Conference, RELATIONAL
10
Session
Attendee Speaker
N 1
N M
ATTENDEE
AID NAME
A1 Jill
A2 Sanjay
SESSION
SID NAME ROOM SPID
S1 JSON OSLO SP1
S2 SQL TOKYO SP2
SPEAKER
SPID NAME PHONE
SP1 Carla 650..
SP2 Pascal 408...
ATT_SES_MAP
AID SID
A1 S1
A2 S2
References, Links -> used for Joins
Copyright © 2024, Oracle and/or its affiliates
• No data duplication -> consistency
• Use case flexibility, SQL
• only select columns that are needed
• query can start at any table and include any other table (joins)
• example: Attendee Schedule, Speaker Schedule, Session Catalog, Session with most Attendees,...
• Relational model relies on algebra: Optimizer
Relational: the GOOD
11
SESSION
SID NAME ROOM SPID
S1 JSON OSLO SP1
S2 SQL TOKYO SP2
SPEAKER
SPID NAME PHONE
SP1 Carla 650..
SP2 Pascal 408...
ATT_SES_MAP
AID SID
A1 S1
A2 S2
ATTENDEE
AID NAME
A1 Jill
A2 Sanjay
Copyright © 2024, Oracle and/or its affiliates
• Needs definition of all tables, columns, data types
• requires perfect upfront knowledge
• schema first, data later
• Hard to evolve, not schema-flexible
• 'Normalization' breaks business objects into many tables
• SQL usually not integrated into programming language (SQL is a string or generated by
ORM)
Relational: the BAD
12
ATTENDEE
AID NAME
A1 Jill
A2 Carla
SESSION
SID NAME ROOM SPID
S1 JSON OSLO SP1
S2 SQL TOKYO SP2
SPEAKER
SPID NAME PHONE
SP1 Beda 650..
SP2 Zhen 408...
ATT_SES_MAP
AID SID
A1 S1
A2 S2
Developing apps using normalized tables is very flexible,
but it is not always easy for developers
App Dev Example — Conference Schedule
AT T E N D E E
S P E A K E R
S E S S I O N
AT T _ S E S S _ M A P
To build Jill’s schedule, the developer must run
database operations on each of the four tables
SQL
SQL
SQL
SQL
Copyright © 2024, Oracle and/or its affiliates
13
SESSION SCHEDULE FOR JILL
( A C M E I N C )
Time 4:00 PM
Room B405
Teacher Beda
Time 2:00 PM
Room A102
Teacher Pascal
Hackolade Demo SQL for Dummies
Relational Data and Developers
Ideally, the developer wants to build Jill’s schedule
using a single simple database operation
Database
Operation
Copyright © 2024, Oracle and/or its affiliates
14
SESSION SCHEDULE FOR JILL
( A C M E I N C )
Time 4:00 PM
Room B405
Teacher Beda
Time 2:00 PM
Room A102
Teacher Pascal
Hackolade Demo SQL for Dummies
Copyright © 2024, Oracle and/or its affiliates
JSON: Hierarchy 1 – Attendee Schedule
15
one object per Attendee
Session
Attendee
Speaker
{
"_id" : "3245",
"name" : "Jill",
"company" : "ACME Inc",
"schedule" : [
{
"code" : "DB12",
"session" : "SQL",
"time" : "14:00",
"room" : "A102",
"speaker" : "Adam"
},
{
"code" : "CODE3",
"session" : "NodeJs",
"time" : "16:00",
"room" : "R12",
"speaker" : "Claudia"
}
]
}
Copyright © 2024, Oracle and/or its affiliates
JSON: Hierarchy 2 – Session Catalog
16
one object per Session {
"code" : "DB12",
"name". : "SQL",
"time" : "14:00",
"room" : "A102",
"speaker" : "Adam",
"numAtt" : 12,
"roomCap" : 60
}
{
"code" : "CODE2",
"name". : "NodeJS",
"time" : "16:00",
"room" : "R12",
"speaker" : "Claudia",
"numAtt" : 75,
"roomCap" : 75
}
Session
Attendee
Speaker
Copyright © 2024, Oracle and/or its affiliates
JSON: Hierarchy 3 – Speaker Schedule
17
one object per Speaker {
"speakerId" : "S1",
"name". : "Adam",
"phone" : "650-392-000",
}
{
"speakerId" : "S2",
"name". : "Claudia",
"phone" : "+49 871 393",
}
Session
Speaker
Copyright © 2024, Oracle and/or its affiliates
• All information for the usecase in one object
• Usually retrieved by a simple 'get' operation from the app code (no SQL)
• Schema flexible
• data first, schema later
• Single hierarchy only possible for simple use cases
• Embedding causes duplication
• Harder to keep consistent and to optimize
JSON: the GOOD, the BAD
18
Copyright © 2024, Oracle and/or its affiliates
19
Can't we normalize JSON
the same way as tables?
Copyright © 2024, Oracle and/or its affiliates
Document Database Normalization
20
{
"attendee : "S3245",
"name" : "Jill",
"schedule" :
[ {
"time" : "14:00",
"session" : "SQL++",
"room" : "A102",
"speaker" : "Adam"
},
…
]
}
S C H E D U L E F O R : J I L L
{
"attendee" : "S3245",
[ {"session" : "M201 }
… ]
}
{
"attendeeId" : "S3245",
"name" : "Jill",
"company" : "ACME
inc"
…}
The Schedule
document can be
changed to reference
a separate Attendee
document instead of
embedding it
Copyright © 2024, Oracle and/or its affiliates
Document Database Normalization
21
{
"attendee : "S3245",
"name" : "Jill",
"schedule" :
[ {
"time" : "14:00",
"session" : "SQL++",
"room" : "A102",
"speaker" : "Adam"
},
…
]
}
S C H E D U L E F O R : J I L L
{
"attendee" : "S3245",
[ {"session" : "M201 }
… ]
}
{
"attendeeId" : "S3245",
"name" : "Jill",
"company" : "ACME inc"
…}
{
"sessionId" : "M201",
"name" : "SQL++",
"teacher" : "T543"
…}
and reference a
separate Session
document
Copyright © 2024, Oracle and/or its affiliates
Document Database Normalization
22
{
"attendee : "S3245",
"name" : "Jill",
"schedule" :
[ {
"time" : "14:00",
"session" : "SQL++",
"room" : "A102",
"speaker" : "Adam"
},
…
]
}
S C H E D U L E F O R : J I L L
{
"attendee" : "S3245",
[ {"session" : "M201 }
… ]
}
{
"attendeeId" : "S3245",
"name" : "Jill",
"company" : "ACME inc"
…}
{
"sessionId" : "M201",
"name" : "SQL++",
"teacher" : "T543"
…}
{
”speakerId" :
"T543",
"name" : "Adam"
…}
which references a
separate Speaker
document
Copyright © 2024, Oracle and/or its affiliates
23
When documents
are normalized
their simplicity is lost
Document Database Fragmentation
Copyright © 2024, Oracle and/or its affiliates
24
AT T E N D E E
S P E A K E R
S E S S I O N
S C H E D U L E
Normalizing documents
produces the worst of both
worlds
• The document structure now
mirrors the normalized table
schema
{
"attendeeId" : "S3245",
[ {"course" : "M201 }
… ]
}
{
”speakerId" :
"T543",
"name" : "Adam"
…}
{
"sessionId" : "M201",
"name" : "Math
201",
"speaker" : "T543"
…}
{
"atendeeId" : "S3245",
"name" : "Jill",
"company" : "ACME
Inc"
…}
Document Database Fragmentation
Copyright © 2024, Oracle and/or its affiliates
25
AT T E N D E E
S P E A K E R
S E S S I O N
S C H E D U L E
{
"attendeeId" : "S3245",
[ {"course" : "M201 }
… ]
}
{
”speakerId" :
"T543",
"name" : "Adam"
…}
{
"sessionId" : "M201",
"name" : "Math
201",
"speaker" : "T543"
…}
{
"atendeeId" : "S3245",
"name" : "Jill",
"company" : "ACME
Inc"
…}
The simplicity of
documents at the
application level is lost
• Without gaining the power of
SQL and relational at the
database level
Performance suffers due
to reference chasing and
loss of shard locality
• Referential integrity must be
enforced by every app
Big Picture - Documents
Copyright © 2024, Oracle and/or its affiliates
26
JSON
Benefits
Use Case Complexity
Documents are great
for simple apps
Big Picture - Documents
Copyright © 2024, Oracle and/or its affiliates
27
JSON
Benefits
Use Case Complexity
Become hazardous as
apps get more complex
Because of this,
many data experts
consider pure Document
Databases an anti-
pattern
Big Picture – Relational
Copyright © 2024, Oracle and/or its affiliates
28
Benefits
Use Case Complexity
Relational
Relational is not as
easy for simple apps
Its power becomes
vital as app complexity
increases
Copyright © 2024, Oracle and/or its affiliates
Benefits
Use Case Complexity
JSON
Oracle Enables Developers to Deliver the Best of Both
With Oracle, developers
can already choose the
data format that
maximizes the benefits
for each use case
29
Relational
Copyright © 2024, Oracle and/or its affiliates
30
This is great
Can we do even better?
Copyright © 2024, Oracle and/or its affiliates
31
Instead of choosing
Relational OR Documents
Can we get the benefits of
Relational PLUS Documents?
Copyright © 2024, Oracle and/or its affiliates
Benefits
Use Case Complexity
JSON
Relational
Can We Get All the Benefits of Both, for Every Use Case?
PLUS
32
JSON PLUS
Relational
Relational
• Use Case Flexibility
• Queryability
• Consistency
• Space Efficiency
Document
• Easy mapping to language types
• Agile schema-less development
• Hierarchical data format
• Standard interchange format
Copyright © 2024, Oracle and/or its affiliates
33
It’s here, we call it
JSON Document Relational Duality
JSON Document Relational Duality
Data is stored as rows
in tables to provide the benefits of the
relational model and SQL access
Storage Format
Copyright © 2024, Oracle and/or its affiliates
34
Rows can include JSON columns to store data
whose schema is dynamic or evolving
TA B L E
Column 1 Column 2 Column 3
… … …
… … …
… … …
… … …
TA B L E
Column 1 Column 2 Column 3
… … …
… … …
… … …
… … …
TA B L E
Column 1 Column 2 Column 3
… … …
… … …
… … …
… … …
JSON Document Relational Duality
Data is stored as rows
in tables to provide the benefits of the
relational model and SQL access
Storage Format
Copyright © 2024, Oracle and/or its affiliates
35
Data can be accessed as JSON
documents
to deliver the application simplicity of
documents
Access Formats
{
"label1" : "String
Anita",
"label2" : 5678
"label3" : ”Physics
201",
}
{
"label1" : ”Student
Jill",
"label2" : 5678
"label3" : ”Science
102",
}
{
"name1" : "String
Value1",
"name2" :
{
"name3" : "14:00",
"name4" : 1234
}
}
TA B L E
Column 1 Column 2 Column 3
… … …
… … …
… … …
… … …
TA B L E
Column 1 Column 2 Column 3
… … …
… … …
… … …
… … …
TA B L E
Column 1 Column 2 Column 3
… … …
… … …
… … …
… … …
CREATE JSON DUALITY VIEW attendeeSchedule
AS attendee
{
_id : aid
name : name
company : company
schedule : attendee_sessions
[ {
session @unnest
{
code : sid
session : sname
time : time
room : room
speaker @unnest
{
speaker : sname
}
}
} ]
};
{
"_id" : "3245",
"name" : "Jill",
"company" : "ACME Inc",
"schedule" : [
{
"code" : "DB12",
"session" : "SQL",
"time" : "14:00",
"room" : "A102",
"speaker" : "Adam"
},
…
]
}
The structure of the view mirrors the structure of the
desired JSON, making it simple to define
Uses familiar
GraphQL syntax
S C H E D U L E F O R : J I L L
CREATE JSON DUALITY VIEW attendeeSchedule
AS attendee
{
_id : aid
name : name
company : company
schedule : attendee_sessions
[ {
session
{
code : sid
session : sname
time : time
room : room
speaker
{
speaker : sname
}
}
} ]
};
The view simply specifies the tables that contain the
data to include in the JSON document
S P E A K E R
S E S S I O N
AT T E N D E E
AT T E N D E E _ S E S S I O N
CREATE JSON DUALITY VIEW attendeeSchedule
AS attendee
{
_id : aid
name : name
company : company
schedule : attendee_sessions
[ {
session
{
code : sid
session : sname
time : time
room : room
speaker
{
speaker : sname
}
}
} ]
};
The view simply specifies the tables that contain the
data to include in the JSON document
AT T E N D E E
AID NAME COMPANY
PHON
E
3245 Jill ACME Inc 650
… … … …
… … … …
… … … …
CREATE JSON DUALITY VIEW attendeeSchedule
AS attendee
{
_id : aid
name : name
company : company
schedule : attendee_sessions @delete @insert @Update
[ {
session
{
code : sid
session : sname
time : time
room : room
speaker
{
speaker : sname
}
}
} ]
};
And specifies the updatability rules
Attendees can update their schedule, but not speaker, rooms, or speakers
CREATE JSON DUALITY VIEW attendeeSchedule
AS attendee
{
_id : aid
name : name
company : company
schedule : attendee_sessions
[ {
session
{
code : sid
session : sname
time : time
room : room
speaker @unnest
{
speaker : sname
}
}
} ]
};
Also specifies when properties in a nested object
should be unnested into the parent
Copyright © 2024, Oracle and/or its affiliates
Example of Using Duality Views
41
Selecting from the schedule Duality View accesses the
underlying tables and returns Jill’s schedule as a JSON
document
• This document has all the data needed by the use case
• And the IDs needed to update the data
{
"_id" : "3245",
"name" : "Jill",
"company" : "ACME Inc",
"schedule" : [
{
"code" : "DB12",
"session" : "SQL",
"time" : "14:00",
"room" : "A102",
"speaker" : "Adam"
},
{
"code" : "CODE3",
"session" : "NodeJs",
"time" : "16:00",
"room" : "R12",
"speaker" : "Claudia"
}
]
}
S C H E D U L E F O R : J I L L
Copyright © 2024, Oracle and/or its affiliates
Example of Using Duality Views
42
You can access the view using SQL or document APIs
SELECT data
FROM student_schedule s
WHERE s.data.name = 'Jill';
student_schedule.find({"name":"Jill
"})
S C H E D U L E F O R : J I L L
{
"_id" : "3245",
"name" : "Jill",
"company" : "ACME Inc",
"schedule" : [
{
"code" : "DB12",
"session" : "SQL",
"time" : "14:00",
"room" : "A102",
"speaker" : "Adam"
},
{
"code" : "CODE3",
"session" : "NodeJs",
"time" : "16:00",
"room" : "R12",
"speaker" : "Claudia"
}
]
}
Copyright © 2024, Oracle and/or its affiliates
Extreme Simplicity for Developers
43
Database
App
GET Doc
PUT Doc
Change Doc
JSON Duality Views are extremely simple to
access:
• GET a document from the View
• Make any changes needed to the document
• PUT the document back into the View
Copyright © 2024, Oracle and/or its affiliates
Extreme Simplicity for Developers
44
Database
App
GET Doc
PUT Doc
Change Doc
The database automatically detects the changes
in the new document and modifies the underlying
rows
• All duality views that share the same data
immediately reflect this change
• Developers no longer worry about
inconsistencies
Copyright © 2024, Oracle and/or its affiliates
The database automatically detects when the
database data underlying a document has changed
between the initial document read and the
subsequent write
• If a change occurred, the write operation is
automatically rejected and returns an error
• The app can then reissue the write based on
the changed data
Game Changing Lock-Free Concurrency Control
45
Database
App
GET Doc
PUT Doc
Change Doc
Reject if
Stored Data
Changed
Called Optimistic Concurrency Control
Copyright © 2024, Oracle and/or its affiliates
• Regardless of the role anyone can work on the same data set whether JSON or relational
and can also build blended applications. Developers can use JSON Relational Duality to
efficiently join relational and JSON (semi-unstructured) data.
• Data consistency and integrity across data models and use cases as data is always
current and with no lagging and staleness.
• Data stored in Duality Views can be accessed via SQL, REST, document APIs (MongoDB
compatible) and many languages and drivers/tool, giving developers broad choices for all
use cases.
JSON Relational Duality Views Benefits I
46
Copyright © 2024, Oracle and/or its affiliates
• Better database performance and scalability for mixed workloads (relational +
semi-structured).
• Duality View eliminates the need for complex ORMs outside the database because
the app developers can directly map programming objects to Duality Views.
• Duality Views are programming language independent where as ORMs support
only one programming language. All that makes app development simple and
agile.
JSON Relational Duality Views Benefits II
47
Copyright © 2024, Oracle and/or its affiliates
48
Architecturally provides
the use-case simplicity of JSON
with the multi-use case
power of relational
Copyright © 2024, Oracle and/or its affiliates
49
Database Software
Going beyond ORMs with JSON Relational Duality Views
Going beyond ORMs with JSON Relational Duality Views
Going beyond ORMs with JSON Relational Duality Views
Going beyond ORMs with JSON Relational Duality Views
https://github.com/gvenzl/oci-oracle-free
https://github.com/gvenzl/oci-oracle-xe
Testcontainers
How many people have heard about Testcontainers?
Going beyond ORMs with JSON Relational Duality Views
Copyright © 2024, Oracle and/or its affiliates
58
Demo
Copyright © 2024, Oracle and/or its affiliates
Try Everything…for FREE
free-oracle.github.io cloud.oracle.com/free oracle.com/database/
free/
oracle.com/livelabs
59
Thank you
@aalmiray
60

More Related Content

PDF
Will Oracle 23ai make you a better DBA or Developer?
PPTX
Manage online profiles with oracle no sql database tht10972 - v1.1
PDF
Java EE 7 overview
PDF
Oracle Application Express 20.2 New Features
 
PPTX
Document Model for High Speed Spark Processing
PPTX
Singpore Oracle Sessions III - What is truly useful in Oracle Database 12c fo...
PDF
Looking Inside the MySQL 8.0 Document Store
PDF
Application development with Oracle NoSQL Database 3.0
Will Oracle 23ai make you a better DBA or Developer?
Manage online profiles with oracle no sql database tht10972 - v1.1
Java EE 7 overview
Oracle Application Express 20.2 New Features
 
Document Model for High Speed Spark Processing
Singpore Oracle Sessions III - What is truly useful in Oracle Database 12c fo...
Looking Inside the MySQL 8.0 Document Store
Application development with Oracle NoSQL Database 3.0

Similar to Going beyond ORMs with JSON Relational Duality Views (20)

PPTX
Oracle BPM Open Data Services (Part 1)
PPTX
REST Enabling Your Oracle Database
PDF
MySQL como Document Store PHP Conference 2017
PDF
NoSQL Introduction
PPTX
NoSQL Introduction
PDF
Spark and MongoDB
PPTX
Crafting Evolvable Api Responses
PDF
Blazing Fast Analytics with MongoDB & Spark
PDF
Oracle Open World 2018 / Code One : MySQL 8.0 Document Store
PPTX
Oracle soa training
PPTX
Elastic search and Symfony3 - A practical approach
PDF
Automating Cloud Operations - Everything you wanted to know about cURL and RE...
PDF
ER/Studio and DB PowerStudio Launch Webinar: Big Data, Big Models, Big News!
PDF
HyperGraphQL
PPTX
Oracle Database Management REST API
PPTX
Full-stack Web Development with MongoDB, Node.js and AWS
PPTX
SQL Server Data Services
PDF
SkiPHP -- Database Basics for PHP
PPTX
Hydra: A Vocabulary for Hypermedia-Driven Web APIs
PDF
Write Less (code) With More (Oracle Database 12c New Features)
Oracle BPM Open Data Services (Part 1)
REST Enabling Your Oracle Database
MySQL como Document Store PHP Conference 2017
NoSQL Introduction
NoSQL Introduction
Spark and MongoDB
Crafting Evolvable Api Responses
Blazing Fast Analytics with MongoDB & Spark
Oracle Open World 2018 / Code One : MySQL 8.0 Document Store
Oracle soa training
Elastic search and Symfony3 - A practical approach
Automating Cloud Operations - Everything you wanted to know about cURL and RE...
ER/Studio and DB PowerStudio Launch Webinar: Big Data, Big Models, Big News!
HyperGraphQL
Oracle Database Management REST API
Full-stack Web Development with MongoDB, Node.js and AWS
SQL Server Data Services
SkiPHP -- Database Basics for PHP
Hydra: A Vocabulary for Hypermedia-Driven Web APIs
Write Less (code) With More (Oracle Database 12c New Features)
Ad

More from Andres Almiray (20)

PDF
Dealing with JSON in the relational world
PDF
Deploying to production with confidence 🚀
PDF
Setting up data driven tests with Java tools
PDF
Creando, creciendo, y manteniendo una comunidad de codigo abierto
PDF
Liberando a produccion con confianza
PDF
Liberando a produccion con confidencia
PDF
OracleDB Ecosystem for Java Developers
PDF
Softcon.ph - Maven Puzzlers
PDF
Maven Puzzlers
PDF
Oracle Database Ecosystem for Java Developers
PDF
JReleaser - Releasing at the speed of light
PDF
Building modular applications with the Java Platform Module System and Layrry
PDF
Going Reactive with g rpc
PDF
Building modular applications with JPMS and Layrry
PDF
Taking Micronaut out for a spin
PDF
Apache Groovy's Metaprogramming Options and You
PDF
What I wish I knew about Maven years ago
PDF
What I wish I knew about maven years ago
PDF
The impact of sci fi in tech
PDF
Gradle Ex Machina - Devoxx 2019
Dealing with JSON in the relational world
Deploying to production with confidence 🚀
Setting up data driven tests with Java tools
Creando, creciendo, y manteniendo una comunidad de codigo abierto
Liberando a produccion con confianza
Liberando a produccion con confidencia
OracleDB Ecosystem for Java Developers
Softcon.ph - Maven Puzzlers
Maven Puzzlers
Oracle Database Ecosystem for Java Developers
JReleaser - Releasing at the speed of light
Building modular applications with the Java Platform Module System and Layrry
Going Reactive with g rpc
Building modular applications with JPMS and Layrry
Taking Micronaut out for a spin
Apache Groovy's Metaprogramming Options and You
What I wish I knew about Maven years ago
What I wish I knew about maven years ago
The impact of sci fi in tech
Gradle Ex Machina - Devoxx 2019
Ad

Recently uploaded (20)

PPTX
Big Data Technologies - Introduction.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Cloud computing and distributed systems.
PDF
Machine learning based COVID-19 study performance prediction
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Empathic Computing: Creating Shared Understanding
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
KodekX | Application Modernization Development
 
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
 
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
 
Big Data Technologies - Introduction.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Encapsulation_ Review paper, used for researhc scholars
Cloud computing and distributed systems.
Machine learning based COVID-19 study performance prediction
20250228 LYD VKU AI Blended-Learning.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Empathic Computing: Creating Shared Understanding
Agricultural_Statistics_at_a_Glance_2022_0.pdf
MYSQL Presentation for SQL database connectivity
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Per capita expenditure prediction using model stacking based on satellite ima...
Advanced methodologies resolving dimensionality complications for autism neur...
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
KodekX | Application Modernization Development
 
The Rise and Fall of 3GPP – Time for a Sabbatical?
 
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
CIFDAQ's Market Insight: SEC Turns Pro Crypto
 

Going beyond ORMs with JSON Relational Duality Views

  • 1. Oracle Database Group Oracle Database 23ai Andres Almiray Senior Principal Product Manager Database Group March 2025 Going Beyond ORMS
  • 3. Copyright © 2024, Oracle and/or its affiliates Relational: The good and the bad Documents (JSON): The good and the bad Can we combine the good from both? JSON Relational Duality Views Demo Agenda 3
  • 5. Oracle Converged Database Blockchain tables In-Database Machine Learning Spatial Relational Columnar analytics Property Graph/RDF Native Binary JSON/XML Text Data Transactional Event Queue Vector embeddings Internet of Things External Data
  • 6. Copyright © 2024, Oracle and/or its affiliates Oracle Converged Database 6 REST/GraphQL APEX Programming Languages Java, Python, JavaScript, .Net, PL/SQL, C/C++, etc. SQLcl/SQL Developer
  • 7. Copyright © 2024, Oracle and/or its affiliates Simple Example: Conference 7 Session Attendee Speaker Entities
  • 8. Copyright © 2024, Oracle and/or its affiliates Simple Example: Conference 8 Session Attendee Speaker Relationships, Cardinalities N 1 N M
  • 9. Copyright © 2024, Oracle and/or its affiliates Simple Example: Conference, RELATIONAL 9 Session Attendee Speaker Tables N 1 N M ATTENDEE AID NAME A1 Jill A2 Sanjay SESSION SID NAME ROOM SPID S1 JSON OSLO SP1 S2 SQL TOKYO SP2 SPEAKER SPID NAME PHONE SP1 Carla 650.. SP2 Pascal 408... ATT_SES_MAP AID SID A1 S1 A2 S2
  • 10. Copyright © 2024, Oracle and/or its affiliates Simple Example: Conference, RELATIONAL 10 Session Attendee Speaker N 1 N M ATTENDEE AID NAME A1 Jill A2 Sanjay SESSION SID NAME ROOM SPID S1 JSON OSLO SP1 S2 SQL TOKYO SP2 SPEAKER SPID NAME PHONE SP1 Carla 650.. SP2 Pascal 408... ATT_SES_MAP AID SID A1 S1 A2 S2 References, Links -> used for Joins
  • 11. Copyright © 2024, Oracle and/or its affiliates • No data duplication -> consistency • Use case flexibility, SQL • only select columns that are needed • query can start at any table and include any other table (joins) • example: Attendee Schedule, Speaker Schedule, Session Catalog, Session with most Attendees,... • Relational model relies on algebra: Optimizer Relational: the GOOD 11 SESSION SID NAME ROOM SPID S1 JSON OSLO SP1 S2 SQL TOKYO SP2 SPEAKER SPID NAME PHONE SP1 Carla 650.. SP2 Pascal 408... ATT_SES_MAP AID SID A1 S1 A2 S2 ATTENDEE AID NAME A1 Jill A2 Sanjay
  • 12. Copyright © 2024, Oracle and/or its affiliates • Needs definition of all tables, columns, data types • requires perfect upfront knowledge • schema first, data later • Hard to evolve, not schema-flexible • 'Normalization' breaks business objects into many tables • SQL usually not integrated into programming language (SQL is a string or generated by ORM) Relational: the BAD 12 ATTENDEE AID NAME A1 Jill A2 Carla SESSION SID NAME ROOM SPID S1 JSON OSLO SP1 S2 SQL TOKYO SP2 SPEAKER SPID NAME PHONE SP1 Beda 650.. SP2 Zhen 408... ATT_SES_MAP AID SID A1 S1 A2 S2
  • 13. Developing apps using normalized tables is very flexible, but it is not always easy for developers App Dev Example — Conference Schedule AT T E N D E E S P E A K E R S E S S I O N AT T _ S E S S _ M A P To build Jill’s schedule, the developer must run database operations on each of the four tables SQL SQL SQL SQL Copyright © 2024, Oracle and/or its affiliates 13 SESSION SCHEDULE FOR JILL ( A C M E I N C ) Time 4:00 PM Room B405 Teacher Beda Time 2:00 PM Room A102 Teacher Pascal Hackolade Demo SQL for Dummies
  • 14. Relational Data and Developers Ideally, the developer wants to build Jill’s schedule using a single simple database operation Database Operation Copyright © 2024, Oracle and/or its affiliates 14 SESSION SCHEDULE FOR JILL ( A C M E I N C ) Time 4:00 PM Room B405 Teacher Beda Time 2:00 PM Room A102 Teacher Pascal Hackolade Demo SQL for Dummies
  • 15. Copyright © 2024, Oracle and/or its affiliates JSON: Hierarchy 1 – Attendee Schedule 15 one object per Attendee Session Attendee Speaker { "_id" : "3245", "name" : "Jill", "company" : "ACME Inc", "schedule" : [ { "code" : "DB12", "session" : "SQL", "time" : "14:00", "room" : "A102", "speaker" : "Adam" }, { "code" : "CODE3", "session" : "NodeJs", "time" : "16:00", "room" : "R12", "speaker" : "Claudia" } ] }
  • 16. Copyright © 2024, Oracle and/or its affiliates JSON: Hierarchy 2 – Session Catalog 16 one object per Session { "code" : "DB12", "name". : "SQL", "time" : "14:00", "room" : "A102", "speaker" : "Adam", "numAtt" : 12, "roomCap" : 60 } { "code" : "CODE2", "name". : "NodeJS", "time" : "16:00", "room" : "R12", "speaker" : "Claudia", "numAtt" : 75, "roomCap" : 75 } Session Attendee Speaker
  • 17. Copyright © 2024, Oracle and/or its affiliates JSON: Hierarchy 3 – Speaker Schedule 17 one object per Speaker { "speakerId" : "S1", "name". : "Adam", "phone" : "650-392-000", } { "speakerId" : "S2", "name". : "Claudia", "phone" : "+49 871 393", } Session Speaker
  • 18. Copyright © 2024, Oracle and/or its affiliates • All information for the usecase in one object • Usually retrieved by a simple 'get' operation from the app code (no SQL) • Schema flexible • data first, schema later • Single hierarchy only possible for simple use cases • Embedding causes duplication • Harder to keep consistent and to optimize JSON: the GOOD, the BAD 18
  • 19. Copyright © 2024, Oracle and/or its affiliates 19 Can't we normalize JSON the same way as tables?
  • 20. Copyright © 2024, Oracle and/or its affiliates Document Database Normalization 20 { "attendee : "S3245", "name" : "Jill", "schedule" : [ { "time" : "14:00", "session" : "SQL++", "room" : "A102", "speaker" : "Adam" }, … ] } S C H E D U L E F O R : J I L L { "attendee" : "S3245", [ {"session" : "M201 } … ] } { "attendeeId" : "S3245", "name" : "Jill", "company" : "ACME inc" …} The Schedule document can be changed to reference a separate Attendee document instead of embedding it
  • 21. Copyright © 2024, Oracle and/or its affiliates Document Database Normalization 21 { "attendee : "S3245", "name" : "Jill", "schedule" : [ { "time" : "14:00", "session" : "SQL++", "room" : "A102", "speaker" : "Adam" }, … ] } S C H E D U L E F O R : J I L L { "attendee" : "S3245", [ {"session" : "M201 } … ] } { "attendeeId" : "S3245", "name" : "Jill", "company" : "ACME inc" …} { "sessionId" : "M201", "name" : "SQL++", "teacher" : "T543" …} and reference a separate Session document
  • 22. Copyright © 2024, Oracle and/or its affiliates Document Database Normalization 22 { "attendee : "S3245", "name" : "Jill", "schedule" : [ { "time" : "14:00", "session" : "SQL++", "room" : "A102", "speaker" : "Adam" }, … ] } S C H E D U L E F O R : J I L L { "attendee" : "S3245", [ {"session" : "M201 } … ] } { "attendeeId" : "S3245", "name" : "Jill", "company" : "ACME inc" …} { "sessionId" : "M201", "name" : "SQL++", "teacher" : "T543" …} { ”speakerId" : "T543", "name" : "Adam" …} which references a separate Speaker document
  • 23. Copyright © 2024, Oracle and/or its affiliates 23 When documents are normalized their simplicity is lost
  • 24. Document Database Fragmentation Copyright © 2024, Oracle and/or its affiliates 24 AT T E N D E E S P E A K E R S E S S I O N S C H E D U L E Normalizing documents produces the worst of both worlds • The document structure now mirrors the normalized table schema { "attendeeId" : "S3245", [ {"course" : "M201 } … ] } { ”speakerId" : "T543", "name" : "Adam" …} { "sessionId" : "M201", "name" : "Math 201", "speaker" : "T543" …} { "atendeeId" : "S3245", "name" : "Jill", "company" : "ACME Inc" …}
  • 25. Document Database Fragmentation Copyright © 2024, Oracle and/or its affiliates 25 AT T E N D E E S P E A K E R S E S S I O N S C H E D U L E { "attendeeId" : "S3245", [ {"course" : "M201 } … ] } { ”speakerId" : "T543", "name" : "Adam" …} { "sessionId" : "M201", "name" : "Math 201", "speaker" : "T543" …} { "atendeeId" : "S3245", "name" : "Jill", "company" : "ACME Inc" …} The simplicity of documents at the application level is lost • Without gaining the power of SQL and relational at the database level Performance suffers due to reference chasing and loss of shard locality • Referential integrity must be enforced by every app
  • 26. Big Picture - Documents Copyright © 2024, Oracle and/or its affiliates 26 JSON Benefits Use Case Complexity Documents are great for simple apps
  • 27. Big Picture - Documents Copyright © 2024, Oracle and/or its affiliates 27 JSON Benefits Use Case Complexity Become hazardous as apps get more complex Because of this, many data experts consider pure Document Databases an anti- pattern
  • 28. Big Picture – Relational Copyright © 2024, Oracle and/or its affiliates 28 Benefits Use Case Complexity Relational Relational is not as easy for simple apps Its power becomes vital as app complexity increases
  • 29. Copyright © 2024, Oracle and/or its affiliates Benefits Use Case Complexity JSON Oracle Enables Developers to Deliver the Best of Both With Oracle, developers can already choose the data format that maximizes the benefits for each use case 29 Relational
  • 30. Copyright © 2024, Oracle and/or its affiliates 30 This is great Can we do even better?
  • 31. Copyright © 2024, Oracle and/or its affiliates 31 Instead of choosing Relational OR Documents Can we get the benefits of Relational PLUS Documents?
  • 32. Copyright © 2024, Oracle and/or its affiliates Benefits Use Case Complexity JSON Relational Can We Get All the Benefits of Both, for Every Use Case? PLUS 32 JSON PLUS Relational Relational • Use Case Flexibility • Queryability • Consistency • Space Efficiency Document • Easy mapping to language types • Agile schema-less development • Hierarchical data format • Standard interchange format
  • 33. Copyright © 2024, Oracle and/or its affiliates 33 It’s here, we call it JSON Document Relational Duality
  • 34. JSON Document Relational Duality Data is stored as rows in tables to provide the benefits of the relational model and SQL access Storage Format Copyright © 2024, Oracle and/or its affiliates 34 Rows can include JSON columns to store data whose schema is dynamic or evolving TA B L E Column 1 Column 2 Column 3 … … … … … … … … … … … … TA B L E Column 1 Column 2 Column 3 … … … … … … … … … … … … TA B L E Column 1 Column 2 Column 3 … … … … … … … … … … … …
  • 35. JSON Document Relational Duality Data is stored as rows in tables to provide the benefits of the relational model and SQL access Storage Format Copyright © 2024, Oracle and/or its affiliates 35 Data can be accessed as JSON documents to deliver the application simplicity of documents Access Formats { "label1" : "String Anita", "label2" : 5678 "label3" : ”Physics 201", } { "label1" : ”Student Jill", "label2" : 5678 "label3" : ”Science 102", } { "name1" : "String Value1", "name2" : { "name3" : "14:00", "name4" : 1234 } } TA B L E Column 1 Column 2 Column 3 … … … … … … … … … … … … TA B L E Column 1 Column 2 Column 3 … … … … … … … … … … … … TA B L E Column 1 Column 2 Column 3 … … … … … … … … … … … …
  • 36. CREATE JSON DUALITY VIEW attendeeSchedule AS attendee { _id : aid name : name company : company schedule : attendee_sessions [ { session @unnest { code : sid session : sname time : time room : room speaker @unnest { speaker : sname } } } ] }; { "_id" : "3245", "name" : "Jill", "company" : "ACME Inc", "schedule" : [ { "code" : "DB12", "session" : "SQL", "time" : "14:00", "room" : "A102", "speaker" : "Adam" }, … ] } The structure of the view mirrors the structure of the desired JSON, making it simple to define Uses familiar GraphQL syntax S C H E D U L E F O R : J I L L
  • 37. CREATE JSON DUALITY VIEW attendeeSchedule AS attendee { _id : aid name : name company : company schedule : attendee_sessions [ { session { code : sid session : sname time : time room : room speaker { speaker : sname } } } ] }; The view simply specifies the tables that contain the data to include in the JSON document S P E A K E R S E S S I O N AT T E N D E E AT T E N D E E _ S E S S I O N
  • 38. CREATE JSON DUALITY VIEW attendeeSchedule AS attendee { _id : aid name : name company : company schedule : attendee_sessions [ { session { code : sid session : sname time : time room : room speaker { speaker : sname } } } ] }; The view simply specifies the tables that contain the data to include in the JSON document AT T E N D E E AID NAME COMPANY PHON E 3245 Jill ACME Inc 650 … … … … … … … … … … … …
  • 39. CREATE JSON DUALITY VIEW attendeeSchedule AS attendee { _id : aid name : name company : company schedule : attendee_sessions @delete @insert @Update [ { session { code : sid session : sname time : time room : room speaker { speaker : sname } } } ] }; And specifies the updatability rules Attendees can update their schedule, but not speaker, rooms, or speakers
  • 40. CREATE JSON DUALITY VIEW attendeeSchedule AS attendee { _id : aid name : name company : company schedule : attendee_sessions [ { session { code : sid session : sname time : time room : room speaker @unnest { speaker : sname } } } ] }; Also specifies when properties in a nested object should be unnested into the parent
  • 41. Copyright © 2024, Oracle and/or its affiliates Example of Using Duality Views 41 Selecting from the schedule Duality View accesses the underlying tables and returns Jill’s schedule as a JSON document • This document has all the data needed by the use case • And the IDs needed to update the data { "_id" : "3245", "name" : "Jill", "company" : "ACME Inc", "schedule" : [ { "code" : "DB12", "session" : "SQL", "time" : "14:00", "room" : "A102", "speaker" : "Adam" }, { "code" : "CODE3", "session" : "NodeJs", "time" : "16:00", "room" : "R12", "speaker" : "Claudia" } ] } S C H E D U L E F O R : J I L L
  • 42. Copyright © 2024, Oracle and/or its affiliates Example of Using Duality Views 42 You can access the view using SQL or document APIs SELECT data FROM student_schedule s WHERE s.data.name = 'Jill'; student_schedule.find({"name":"Jill "}) S C H E D U L E F O R : J I L L { "_id" : "3245", "name" : "Jill", "company" : "ACME Inc", "schedule" : [ { "code" : "DB12", "session" : "SQL", "time" : "14:00", "room" : "A102", "speaker" : "Adam" }, { "code" : "CODE3", "session" : "NodeJs", "time" : "16:00", "room" : "R12", "speaker" : "Claudia" } ] }
  • 43. Copyright © 2024, Oracle and/or its affiliates Extreme Simplicity for Developers 43 Database App GET Doc PUT Doc Change Doc JSON Duality Views are extremely simple to access: • GET a document from the View • Make any changes needed to the document • PUT the document back into the View
  • 44. Copyright © 2024, Oracle and/or its affiliates Extreme Simplicity for Developers 44 Database App GET Doc PUT Doc Change Doc The database automatically detects the changes in the new document and modifies the underlying rows • All duality views that share the same data immediately reflect this change • Developers no longer worry about inconsistencies
  • 45. Copyright © 2024, Oracle and/or its affiliates The database automatically detects when the database data underlying a document has changed between the initial document read and the subsequent write • If a change occurred, the write operation is automatically rejected and returns an error • The app can then reissue the write based on the changed data Game Changing Lock-Free Concurrency Control 45 Database App GET Doc PUT Doc Change Doc Reject if Stored Data Changed Called Optimistic Concurrency Control
  • 46. Copyright © 2024, Oracle and/or its affiliates • Regardless of the role anyone can work on the same data set whether JSON or relational and can also build blended applications. Developers can use JSON Relational Duality to efficiently join relational and JSON (semi-unstructured) data. • Data consistency and integrity across data models and use cases as data is always current and with no lagging and staleness. • Data stored in Duality Views can be accessed via SQL, REST, document APIs (MongoDB compatible) and many languages and drivers/tool, giving developers broad choices for all use cases. JSON Relational Duality Views Benefits I 46
  • 47. Copyright © 2024, Oracle and/or its affiliates • Better database performance and scalability for mixed workloads (relational + semi-structured). • Duality View eliminates the need for complex ORMs outside the database because the app developers can directly map programming objects to Duality Views. • Duality Views are programming language independent where as ORMs support only one programming language. All that makes app development simple and agile. JSON Relational Duality Views Benefits II 47
  • 48. Copyright © 2024, Oracle and/or its affiliates 48 Architecturally provides the use-case simplicity of JSON with the multi-use case power of relational
  • 49. Copyright © 2024, Oracle and/or its affiliates 49 Database Software
  • 56. Testcontainers How many people have heard about Testcontainers?
  • 58. Copyright © 2024, Oracle and/or its affiliates 58 Demo
  • 59. Copyright © 2024, Oracle and/or its affiliates Try Everything…for FREE free-oracle.github.io cloud.oracle.com/free oracle.com/database/ free/ oracle.com/livelabs 59