Wednesday, March 17, 2021

How to Simplify Development and Optimize your Data with Oracle's Converged Database

 In our digitized, data-fueled world, enterprises must create unique assets — and make the most of them — in order to remain competitive. This puts developers front and center when it comes to managing and optimizing database performance. Developers not only shape the underlying technologies throughout the stack, they now drive efficiency and best-practices from a variety of hybrid roles (DevOps, Full-Stack, etc.). But developers are often forced to choose between data productivity or their own. 

Oracle's converged database has rendered that dilemma obsolete.

Developers know better than anyone that the digital landscape is ever-changing. New languages, new frameworks, new tools, new protocols — the demands and opportunities can quickly become overwhelming unless there’s a clear signal amid the noise. In keeping with the KISS (“keep it simple”) principle, developers strive for modern development while not sacrificing operational efficiencies required to keep their companies competitive.

Single-purpose databases, often known as purpose-built databases, are engineered to solve targeted problems. However, when operations grow, integration of multiple single-purpose databases is required. 

Enter Oracle's converged database — a platform loaded with a suite of capabilities that are simpler, easier, and far less error-prone than multiple single-purpose databases combined. 

In this article, we’ll highlight a few key advantages delivered by Oracle converged database that help our customers keep it simple while staying smart. Development Smart. Especially when developing with multiple data types.

As companies pursue the efficiency and relevancy necessary for their success, they must digitize complex processes and data-integration at scale. As a result, developer teams are faced with a difficult choice: optimize for fast application-development now, or prioritize easier data-capture later. Developer productivity or data productivity. It’s a difficult either/or.

In the first case (developer productivity), developer teams might spin-up single-purpose databases for specific projects (especially when it comes to greenfield development). Each database offers a low barrier for entry that often includes a convenient data model for the purpose at hand along with related APIs. Development moves quickly, as each database has its own operational characteristics that are useful in the immediate. But as a project grows and additional databases or cloud services are required, complexity multiplies and data fragments. Efficiencies gained are quickly lost, as each database’s once-enticing characteristics no longer function at scale. As a result, developer teams face long-term difficulties such as lack of standardization (APIs, query languages, etc.), data fragmentation, security risks, and management gaps.

Oracle Database Tutorial and Material, Oracle Database Preparation, Oracle Database Prep, Database Career
A snapshot of some of the integration difficulties produced by single-purpose databases.

In the second case (data productivity), especially when it comes to brownfield projects, developers might build on a corporate standard database that’s usually a generic relational or relational multi-model database. But while the corporate standard database enforces official policies and simplifies things such as operations, security, and data reuse (reporting, analytics, etc.), limited functionality can often slow and even prevent innovation. This risks putting the entire business at a disadvantage in a fast-paced, highly competitive market landscape.

Neither of the above scenarios are ideal, and both are limiting in their own ways. Which begs an important question: What if there were a third option? 

That option is Oracle's converged database — a first-in-class solution that balances both developer and data productivity.

At its highest level, a converged database is a multi-model, multi-tenant, multi-workload architecture (see the graphic below). More specifically, Oracle's converged database delivers the data models and access methods needed for modern development on all workloads (OLAP, OLTP, IoT, etc.). Better, it delivers the specific tooling, security, integration, and operational characteristics developers and developer teams are seeking — powerful, smart capabilities that simplify, streamline, and out-perform at scale.

Oracle Database Tutorial and Material, Oracle Database Preparation, Oracle Database Prep, Database Career
Oracle Database 19c is the world’s first converged database — one that balances developer and data productivity for a powerful solution at scale.

As any developer will tell you, talk is cheap; show me the code. So let’s take a look at two different environments, along with a few code examples, to better understand how Oracle's converged database streamlines the data-tier for development.

We will illustrate the inherent simplicity of using Oracle's converged database on two three-tier environments within a vacation-rental online-marketplace application. (In this case, we’ll use an Airbnb clone named “Host-a-bnb,” depicted in the graphic below.)

The unique data assets required for this application are:

1. Key-Value (used to store users’ search-histories in order to deliver them quick, personalized future searches)
2. Graph (used to store users’ relationships with one another in order to optimize and enhance social-media features and functionality)
3. Relational (used to store users’ transactions for booking and payments)

The requirements generated by the above translate to the following (for simplicity, we’ll forego including a caching layer):

1. The single-purpose database deployment will consist of MongoDB (key-value), Neo4j (graph), and Firebird (relational) databases.
2. The Oracle Database deployment will consist of a single pluggable database with corresponding tables for key-value, graph, and relational data.

Oracle Database Tutorial and Material, Oracle Database Preparation, Oracle Database Prep, Database Career
A simplified example of Host-a-bnb’s three-tier environment when run on multiple single-databases versus Oracle's converged database.

Within this construct, let’s zero-in on something that should be relatively painless: connecting the "Host-a-bnb" web-application to the corresponding data tiers.

SINGLE-PURPOSE DATABASES

1 # INSTALL NPM MODULES
2 npm i mongo
3 npm i neo4j-driver
4 npm i node-firebird

// DEMONSTRATION PURPOSES ONLY
// JS
// ...
1   // CONNECT TO MONGODB CLIENT
2   let mongoClient = require('mongodb').MongoClient; // includes Mongodb module
3       MongoClient.connect(mongoURL,mongoOptions, (err, client) => {
4          if (err) {/* ERROR HANDLING */} else {/* CONNECTED TO MONGODB */}
5      });
6   // CONNECT TO NEO4J
7   const neo4j = require('neo4j-driver'); //include Neo4j module
8   const driver = neo4j.driver(uri, neo4j.auth.basic(user, password));
9   const neo4jSession = driver.session();
10      try {
11        const result = await neo4jSession.run(/* CONNECTED TO NEO4J */);
12      } finally {
13        await session.close();
14      }
15  // CONNECT TO FIREBIRD CLIENT
16  var Firebird = require('node-firebird'); // include firebird module
17  Firebird.attach(options, function(err, firebirdDB) {
18    if (err) {/* ERROR HANDLING */} else {/* CONNECTED TO FIREBIRD */}  
19  });
// ...
// DEMONSTRATION PURPOSES ONLY

ORACLE DATABASE (CONVERGED)

1 # INSTALL NPM MODULES
2 npm i oracledb
3
4

// DEMONSTRATION PURPOSES ONLY
// JS
// ...
1   // CONNECT TO ORACLE DATABASE CLIENT
2   const oracledb = require('oracledb');
3   function oracleDbConnect(dbOptions) {
4       return new Promise(async (resolve, reject) => {
5           try {
6               await oracledb.getConnection(dbOptions).then(conn => {
7                   resolve(/* CONNECTED TO ORACLE DB */);
8               });
9           } catch (err) {     
10              reject(err);  
11          } 
12      });
13  }
14
15
16
17
18
19
// ...
// DEMONSTRATION PURPOSES ONLY

Oracle Database Tutorial and Material, Oracle Database Preparation, Oracle Database Prep, Database Career
A comparison of data-tier connection across single-purpose databases versus the Oracle converged Database.

As you’ll see in the graphic immediately above, some additional work is required when connecting single-purpose databases. Granted, while this example is trivial, it foreshadows the complexity to come. Looking at the code (below), which demonstrates simple queries from each single-purpose database, things start to get messy – fast.

SINGLE-PURPOSE DATABASES

// DEMONSTRATION PURPOSES ONLY
// JS
// Use Case: Host-a-bnb (vacation rental company) wants to build a dashboard that visualizes session data of users who booked bnbs at a
// given date with long-term friends (> 5 year) and needs to pull out the session data to do it. 
// The query below will pull the session data using predefined variables 'VAR_USER_ID', 'VAR_BOOKING_DT', and 'VAR_FRIENDSHIP_LENGTH'.
// ...
// Step 1.a: Let's apporach this problem by querying and pulling all the 'firebirdBookingIds' the user had on the 'VAR_BOOKING_DT' from Firdbird
firebirdBookingIds = [];
Firebird.attach(options, function(err, firebirdDB) {
    if (err) {/* ERROR HANDLING */} else {/* CONNECTED TO FIREBIRD */}  
    firebirdDB.query('SELECT BOOKING_ID FROM BOOKINGS WHERE USER_ID = ? AND BOOKING_DATE = ?', 
    [VAR_USER_ID, VAR_BOOKING_DT], (err, result) => 
    {
        if (err) throw err;
        // Step 1.b: Clean 'firebirdBookingIds' for use in next step (think ETL, what a pain!)
        firebirdBookingIds = transformResult(result) {/* ... */};
        firebirdDB.detach();
    });
})
// Step 2.a: Then, using the 'firebirdBookingIds', query which bookings included friends with 'VAR_FRIENDSHIP_LENGTH' > 5 years from Neo4j
neo4jFilteredBookingIds = [];
session.run(
    'MATCH (u:Person)-[:IS_FRIENDS_WITH]-(friends) WHERE u.id = $user_id AND friends.friendship_length > $fLength' + 
    'RETURN FILTER(x in friends.booking_ids WHERE x IN $userBookingIds)',
    { userId: VAR_USER_ID,
      fLength: VAR_FRIENDSHIP_LENGTH,
      userBookingIds: firebirdBookingIds
    }).then(result => {
        // Step 2.b: Clean 'neo4jFilteredBookingIds' for use in next step (think ETL, what a pain!)
        neo4jFilteredBookingIds = transformResult(result.records) {/* ... */};
    }).catch (error => {
        console.log(error);
    }).then(() => session.close())
// Step 3: Finally, using 'neo4jFilteredBookingIds', return the session history from MongoDB
finalResult = [];   
MongoClient.connect(url,mongoOptions, (err, client) => {
    if(err) console.log(err);
    const db = client.db(/* DB NAME */);
    const sessionHistoryCollection = db.collection(/* COLLECTION_SESSION_HISTORY */);
    sessionHistoryCollection.find({"booking_id": {"$in": [neo4jFilteredBookingIds]}},{"session_data": 1}).toArray((err, items) => {
        if (err) console.log(err);
            finalResult = items;
    })
});
console.log(finalResults); // Print session history
// ...
// DEMONSTRATION PURPOSES ONLY

A simplified example of querying within a single-purpose database data-tier.

In contrast, Oracle's converged database unified approach can query this data as one would expect. In one query the data is joined together and the desired result is returned. No hassle or transformation between databases or data types.

ORACLE DATABASE (CONVERGED)

// DEMONSTRATION PURPOSES ONLY
// JS
// Use Case: Host-a-bnb (vacation rental company) wants to build a dashboard that visualizes session data of users who booked bnbs at a
// given date with long-term friends (> 5 year) and needs to pull out the session data to do it.
// The query below will pull the session data using predefined variables 'VAR_USER_ID', 'VAR_BOOKING_DT', and 'VAR_FRIENDSHIP_LENGTH'.
// ...
finalResult = [];
oracledb.execute(
    `with booking_cte as ( -- Create temporary result set of needed information from *relational data* on the date 'VAR_BOOKING_DT'
    SELECT BOOKING_ID from BOOKINGS WHERE USER_ID = :1 AND BOOKING_DATE = to_date( :2 , 'MM/DD/YY')
), relationship_cte as ( -- Create temporary result set of needed information from *graph data* where frienships with 'VAR_USER_ID' exist
    SELECT USER_ID, FRIEND_ID, RELATIONSHIP_TYPE, FRIENDSHIP_LENGTH, BOOKING_ID FROM RELATIONSHIPS
    START WITH USER_ID = :3
    CONNECT BY NOCYCLE PRIOR
        USER_ID = FRIEND_ID
), session_history_cte as ( -- Create temporary result set of needed information from *key/value data*
SELECT jt.BOOKING_ID, jt.SESSION_DATA from SESSION_HISTORY,
    json_table( json_doc, '$'
        columns (
            nested path '$.history_of_bookings[*]' columns (
                booking_id number path '$.booking_id',
                session_data FORMAT JSON path '$.session_data'
        ))
    ) jt
)SELECT s.SESSION_DATA FROM booking_cte b 
    JOIN relationship_cte r ON r.BOOKING_ID = b.BOOKING_ID
    JOIN session_history_cte s ON s.BOOKING_ID = r.BOOKING_ID
WHERE r.FRIENDSHIP_LENGTH > :4
-- Finally, query to pull 'SESSION_DATA' from the 'BOOKING_ID's where users booked bnbs on the date 'VAR_BOOKING_DT' with 
-- long term friends ('r.FRIENDSHIP_LENGTH' > VAR_FRIENDSHIP_LENGTH [5 years])`,
    [VAR_USER_ID, VAR_BOOKING_DATE, VAR_USER_ID, VAR_FRIENDSHIP_LENGTH], {outFormat: oracledb.ARRAY}
    ).then(result => {
        finalResult = result;
    }).catch(err => {
        console.log(err);
   });
console.log(finalResult); // Print session history
// ...
// DEMONSTRATION PURPOSES ONLY

A simplified example of querying within the Oracle converged database data-tier.

Oracle Database Tutorial and Material, Oracle Database Preparation, Oracle Database Prep, Database Career
A comparison of querying (QL) within a single-purpose Databases versus the Oracle converged database data-tiers.

The most notable thing to unpack here is that single-purpose databases put developer teams at a disadvantage when querying data. Each database requires its own specific Query Language (QL, referenced in the graphic above). Beyond that, once queried, the data is pulled in pieces, many times, serially. This is in no way efficient from a dev perspective, as each developer must figure out how to minimize three separate datasets for a single application. Moreover, developers must then perform data-integration manually in order to produce the desired result.

As we can see in the query-code example above, Oracle’s converged database solves this problem at the root by using one QL to perform all queries across the database. This allows the database, instead of the developer, to do the heavy lifting.

Oracle Database Tutorial and Material, Oracle Database Preparation, Oracle Database Prep, Database Career
Side-by-side comparison of querying data within single-purpose databases versus the Oracle converged database data-tiers.

Highlighted in the table above, fragmented behavior is systemic in single-purpose database products and significant effort is spent on engineering integrations. As a solution, Oracle’s converged database avoids these pitfalls by providing an inclusive product that not only requires minimum integration but merges cutting-edge functionality across the platform’s architecture. For example, different data types can live in the same table, or can easily be joined together. This cleanly eliminates the need to spin-up another product just to add another data type. Instead, it’s as easy as creating a column or table.

Oracle Database Tutorial and Material, Oracle Database Preparation, Oracle Database Prep, Database Career
Side-by-side comparison of querying analytics within single-purpose databases versus Oracle's converged database data-tiers.

Operational use of the data is only one aspect of data management. With Oracle's converged database, developers can avoid expensive ETL (Extract, Transform, and Load) operations, often required to move data from one database to another (such as from OLTP to OLAP in order to enable analytics and reporting). This pattern of intuitive, simple, high-quality integration extends throughout Oracle's converged database.

Oracle's converged database is built upon years of innovation and sits alongside a full array of tools designed to maximize efficiency and performance. As the second-largest software company in the world, Oracle provides a variety of products that empower developers across the CI/CD process. These include:

1. Helidon.io

◉ A lightweight, microservice Java-framework that provides simplified microservice development. Best of all, it runs anywhere.

2. Coherence

◉ A scalable, fault-tolerant, cloud-ready, distributed platform for building grid-based applications that store data reliably.

3. Docker/cri-o and Kubernetes

◉ Enables cloud-native applications to be built and deployed alongside monolithic applications via Oracle’s support for containerization and orchestration.

4. WLS Kubernetes Operator

◉ Facilitates the easiest way to develop, deploy, and manage Oracle WebLogic. WLS Kubernetes Operator makes it easy to modernize while broadening existing skill-sets.

5. Verrazzano

◉ An enterprise container platform for deploying traditional and cloud-native applications in multi-cloud and hybrid scenarios.

6. Terraform and  Oracle Cloud Infrastructure (OCI)

◉ Allows developers to safely and predictably create, change, and improve Oracle Cloud Infrastructure.

The role of the developer is ever-expanding. And now more than ever, IT processes are driven by code. Oracle understands this. This is why we provide a developer-friendly environment throughout the CI/CD process. No matter the task, and no matter where you sit, our toolsets will help you keep it simple while staying smart. Development Smart. With simple, secure technologies that offer rock-solid reliability.

In a world of increasing complexity that demands ever-increasing efficiency, that’s a powerful thing indeed.

Source: oracle.com

Related Posts

0 comments:

Post a Comment