Hackolade Tutorial
Oracle 23c Duality Views
Copyright © 2016-2023 Hackolade 1
Introduction to Oracle Duality Views
Copyright © 2016-2023 Hackolade 2
Asking the question… is answering it!
Copyright © 2016-2023 Hackolade 3
Summary of that introduction
Copyright © 2016-2023 Hackolade 4
Duality views explained
• JSON-relational duality views combine the advantages of using JSON
documents with the advantages of the relational model, while
avoiding the limitations of each: A duality view exposes data stored
in relational tables as JSON documents
• Duality views are similar to Object-Relational Mappings, but are
different in that they centralise the persistence format of application
objects for all clients (both server-side and client-side applications).
• No need for a mapper: the duality view == the mapping
Copyright © 2016-2023 Hackolade 5
Duality views in Hackolade Studio
• The Hackolade Oracle plugin has been adapted to support the data
modeling of duality views, as well as the forward- and reverse-
engineering of the DDL scripts
• A duality is a “special kind of view”, with properties and columns, but
• nested objects of a special kind can be contained in the view
• the syntax of the DDL script introduces some new vocabulary and structure,
which impacts forward- and reverse-engineering
• See this example repository with a sample DDL
• Includes “data” that can be inserted into 23c database
Copyright © 2016-2023 Hackolade 6
• Relational tables: • Duality views:
Copyright © 2016-2023 Hackolade 7
Example based on DDL: Car racing
Note that the DDL does NOT expose
the structure of “podium”
blob / JSON document!!!
• Relational tables: • Duality views:
Copyright © 2016-2023 Hackolade 8
Example based on database RE: Car racing
Note that the probablistic sampling
of the database RE DOES REVEAL
the structure of “podium”
blob / JSON document!!!
Duality view syntax (SQL only)
Copyright © 2016-2023 Hackolade 9
Creating a duality view
Copyright © 2016-2023 Hackolade 10
You must choose the root
table from the dropdown list
of tables in the
schema. You may
optionally set a root table
alias.
You may also set the Force
and Editionable flags.
You should of course give
your duality view a name. If
Naming Conventions are
enabled, you provide a
business name which gets
transformed into a technical
name according to the set
rules.
Select columns from root table
Copyright © 2016-2023 Hackolade 11
Adding a nested object or array subquery
• A duality view and its corresponding top-
level JSON object provides a hierarchy of
JSON objects and arrays, which are defined
in the view definition using nested SQL
subqueries
• Data gathered from a subquery is joined to data
gathered from a parent subquery or the root
table by a relationship between a primary or
unique key in the parent and a foreign key in
the child subquery's WHERE clause
• The cardinality of relationships dictates whether
you use an object or an array type of subquery.
• You may create multi-level nesting to represent
recursive joins
• To add a subquery, invoke the contextual
menu to append a column and choose
Subquery:
Copyright © 2016-2023 Hackolade 12
Add unnested fields
• unnested subquery allows to select columns in the underlying child
table and present the fields in the JSON at the same level as the
columns of the prent table.
Copyright © 2016-2023 Hackolade 13
Forward-engineer to DDL script
Copyright © 2016-2023 Hackolade 14
Hackolade Studio can also reverse-engineer
DDL files including duality views defines in SQL
syntax. This is particularly useful if it is not
possible to connect the application to the
Oracle database instance.
The drawback of DDL file-based reverse-
engineering however is that, in the event of
columns defined with a JSON data type or LOB
containing JSON documents, the application
will not have a chance to sample JSON in
order to infer the schema. Such information
never appears in DDLs and only Hackolade
Studio is able to infer the schema of JSON in
RDBMS.
Reading material
• See Hackolade online documentation
• The Hackolade Blog
• Hackolade’s on social media: LinkedIn page, Twitter page
• Download Hackolade Studio for free
• This excellent new book:
MongoDB Data Modeling & Schema Design
• Many of the principles in the book are related to query
driven modeling based on access patterns
Copyright © 2016-2023 Hackolade 15
Order on Amazon
Copyright © 2016-2023 Hackolade 16
Pre-order
Upcoming
Copyright © 2016-2023 Hackolade 17
Questions?
Answers!
Copyright © 2016-2023 Hackolade 18

Tutorial Advanced How-To - Oracle 23c Duality views

  • 1.
    Hackolade Tutorial Oracle 23cDuality Views Copyright © 2016-2023 Hackolade 1
  • 2.
    Introduction to OracleDuality Views Copyright © 2016-2023 Hackolade 2
  • 3.
    Asking the question…is answering it! Copyright © 2016-2023 Hackolade 3
  • 4.
    Summary of thatintroduction Copyright © 2016-2023 Hackolade 4
  • 5.
    Duality views explained •JSON-relational duality views combine the advantages of using JSON documents with the advantages of the relational model, while avoiding the limitations of each: A duality view exposes data stored in relational tables as JSON documents • Duality views are similar to Object-Relational Mappings, but are different in that they centralise the persistence format of application objects for all clients (both server-side and client-side applications). • No need for a mapper: the duality view == the mapping Copyright © 2016-2023 Hackolade 5
  • 6.
    Duality views inHackolade Studio • The Hackolade Oracle plugin has been adapted to support the data modeling of duality views, as well as the forward- and reverse- engineering of the DDL scripts • A duality is a “special kind of view”, with properties and columns, but • nested objects of a special kind can be contained in the view • the syntax of the DDL script introduces some new vocabulary and structure, which impacts forward- and reverse-engineering • See this example repository with a sample DDL • Includes “data” that can be inserted into 23c database Copyright © 2016-2023 Hackolade 6
  • 7.
    • Relational tables:• Duality views: Copyright © 2016-2023 Hackolade 7 Example based on DDL: Car racing Note that the DDL does NOT expose the structure of “podium” blob / JSON document!!!
  • 8.
    • Relational tables:• Duality views: Copyright © 2016-2023 Hackolade 8 Example based on database RE: Car racing Note that the probablistic sampling of the database RE DOES REVEAL the structure of “podium” blob / JSON document!!!
  • 9.
    Duality view syntax(SQL only) Copyright © 2016-2023 Hackolade 9
  • 10.
    Creating a dualityview Copyright © 2016-2023 Hackolade 10 You must choose the root table from the dropdown list of tables in the schema. You may optionally set a root table alias. You may also set the Force and Editionable flags. You should of course give your duality view a name. If Naming Conventions are enabled, you provide a business name which gets transformed into a technical name according to the set rules.
  • 11.
    Select columns fromroot table Copyright © 2016-2023 Hackolade 11
  • 12.
    Adding a nestedobject or array subquery • A duality view and its corresponding top- level JSON object provides a hierarchy of JSON objects and arrays, which are defined in the view definition using nested SQL subqueries • Data gathered from a subquery is joined to data gathered from a parent subquery or the root table by a relationship between a primary or unique key in the parent and a foreign key in the child subquery's WHERE clause • The cardinality of relationships dictates whether you use an object or an array type of subquery. • You may create multi-level nesting to represent recursive joins • To add a subquery, invoke the contextual menu to append a column and choose Subquery: Copyright © 2016-2023 Hackolade 12
  • 13.
    Add unnested fields •unnested subquery allows to select columns in the underlying child table and present the fields in the JSON at the same level as the columns of the prent table. Copyright © 2016-2023 Hackolade 13
  • 14.
    Forward-engineer to DDLscript Copyright © 2016-2023 Hackolade 14 Hackolade Studio can also reverse-engineer DDL files including duality views defines in SQL syntax. This is particularly useful if it is not possible to connect the application to the Oracle database instance. The drawback of DDL file-based reverse- engineering however is that, in the event of columns defined with a JSON data type or LOB containing JSON documents, the application will not have a chance to sample JSON in order to infer the schema. Such information never appears in DDLs and only Hackolade Studio is able to infer the schema of JSON in RDBMS.
  • 15.
    Reading material • SeeHackolade online documentation • The Hackolade Blog • Hackolade’s on social media: LinkedIn page, Twitter page • Download Hackolade Studio for free • This excellent new book: MongoDB Data Modeling & Schema Design • Many of the principles in the book are related to query driven modeling based on access patterns Copyright © 2016-2023 Hackolade 15
  • 16.
    Order on Amazon Copyright© 2016-2023 Hackolade 16 Pre-order
  • 17.
  • 18.