diff --git a/23aijsontest/intro/intro.md b/23aijsontest/intro/intro.md deleted file mode 100644 index b6a94be5..00000000 --- a/23aijsontest/intro/intro.md +++ /dev/null @@ -1,36 +0,0 @@ -# Oracle Database 23ai—JSON Support - -## Introduction - -This workshop introduces you to the powerful JSON capabilities in Oracle Database 23ai, focusing on JSON Collection tables and JSON Duality views. Through hands-on labs, you'll learn how these features simplify working with JSON data in a relational database, making it easier to build modern applications that leverage both structured and unstructured data. - -Estimated Workshop Time: 60 minutes - -### About Oracle Database 23ai JSON Features - -Oracle Database 23ai introduces advanced JSON support to bridge the gap between relational and document databases. JSON Collection tables allow you to store and query JSON documents natively, while JSON Duality views provide a unified interface that lets you work with the same data through both relational and JSON paradigms. - -### Objectives - -In this workshop, you will: -* Understand the benefits of JSON Collection tables for document storage -* Learn to create and manipulate JSON collections -* Explore JSON Duality views for seamless data access -* Apply these features to real-world use cases - -### Prerequisites - -This workshop assumes you have: -* Basic knowledge of SQL -* Access to Oracle Database 23ai -* A development environment (SQL Developer or similar) - -## Learn More - -* [Oracle Database 23ai JSON Documentation](https://docs.oracle.com/en/database/oracle/oracle-database/23/adjsn/) -* [JSON Collection Tables](https://docs.oracle.com/en/database/oracle/oracle-database/23/adjsn/json-collection-tables.html) -* [JSON Duality Views](https://docs.oracle.com/en/database/oracle/oracle-database/23/adjsn/json-duality-views.html) - -## Acknowledgements -* **Author** - Oracle LiveLabs Team -* **Last Updated By/Date** - Cline, September 2025 diff --git a/23aijsontest/labs/collection-tables/collection-tables.md b/23aijsontest/labs/collection-tables/collection-tables.md deleted file mode 100644 index b423df59..00000000 --- a/23aijsontest/labs/collection-tables/collection-tables.md +++ /dev/null @@ -1,203 +0,0 @@ -# Lab 1: JSON Collection Tables - -## Introduction - -In this lab, you'll explore JSON Collection tables in Oracle Database 23ai. Imagine you're building an e-commerce platform for a bookstore. Books come in all shapes and sizes—some have ISBN numbers, multiple authors, series information, while others are simple paperbacks. Traditional relational tables with fixed columns would struggle with this variability. JSON Collection tables provide the perfect solution, allowing you to store book information as JSON documents with flexible schemas. - -Estimated Lab Time: 20 minutes - -### Objectives - -* Create a JSON Collection table -* Insert JSON documents representing books -* Query the collection using SQL/JSON functions -* Update and delete documents -* Understand when to use collection tables vs. traditional tables - -### Prerequisites - -* Completed the Introduction lab -* Access to Oracle Database 23ai with SQL Developer - -## Task 1: Create a JSON Collection Table - -Our bookstore needs a way to store book information. We'll create a JSON collection table called `book_catalog`. - -1. Connect to your Oracle Database 23ai instance using SQL Developer. - -2. Run the following SQL to create the collection table: - - ``` - - CREATE JSON COLLECTION TABLE book_catalog; - - ``` - - This creates a table optimized for storing JSON documents. Unlike traditional tables, collection tables automatically handle JSON validation and provide optimized storage and indexing for JSON data. - -## Task 2: Insert Book Documents - -Now let's add some books to our catalog. Each book will be stored as a JSON document. - -1. Insert a classic novel: - - ``` - - INSERT INTO book_catalog VALUES ( - JSON('{ - "title": "Pride and Prejudice", - "author": ["Jane Austen"], - "genre": "Romance", - "published_year": 1813, - "isbn": "978-0141439518", - "pages": 432, - "price": 9.99 - }') - ); - - ``` - -2. Add a modern thriller with multiple authors: - - ``` - - INSERT INTO book_catalog VALUES ( - JSON('{ - "title": "The Silent Patient", - "author": ["Alex Michaelides"], - "genre": "Thriller", - "published_year": 2019, - "isbn": "978-1250301697", - "pages": 336, - "price": 14.99, - "awards": ["Goodreads Choice Awards Best Mystery & Thriller"] - }') - ); - - ``` - -3. Insert a children's book with series information: - - ``` - - INSERT INTO book_catalog VALUES ( - JSON('{ - "title": "The Very Hungry Caterpillar", - "author": ["Eric Carle"], - "genre": "Children", - "published_year": 1969, - "pages": 26, - "price": 8.99, - "series": "Classic Board Books", - "age_range": "2-5 years" - }') - ); - - ``` - - Notice how each document has different fields. The JSON collection table accommodates this flexibility perfectly. - -## Task 3: Query the Book Catalog - -Let's explore our collection with some queries. - -1. View all books: - - ``` - - SELECT * FROM book_catalog; - - ``` - -2. Find books by genre: - - ``` - - SELECT JSON_VALUE(data, '$.title') AS title, - JSON_VALUE(data, '$.genre') AS genre - FROM book_catalog - WHERE JSON_VALUE(data, '$.genre') = 'Romance'; - - ``` - -3. Get books published after 2000: - - ``` - - SELECT JSON_VALUE(data, '$.title') AS title, - JSON_VALUE(data, '$.published_year') AS year - FROM book_catalog - WHERE JSON_VALUE(data, '$.published_year') > 2000; - - ``` - -4. Find books with awards: - - ``` - - SELECT JSON_VALUE(data, '$.title') AS title, - JSON_QUERY(data, '$.awards') AS awards - FROM book_catalog - WHERE JSON_EXISTS(data, '$.awards'); - - ``` - -## Task 4: Update Book Information - -Our bookstore got a price increase. Let's update the prices. - -1. Increase prices by 10% for all books: - - ``` - - UPDATE book_catalog - SET data = JSON_TRANSFORM(data, SET '$.price' = JSON_VALUE(data, '$.price') * 1.1); - - ``` - -2. Add a discount field to children's books: - - ``` - - UPDATE book_catalog - SET data = JSON_TRANSFORM(data, SET '$.discount' = 0.2) - WHERE JSON_VALUE(data, '$.genre') = 'Children'; - - ``` - -## Task 5: Remove Books from Catalog - -Sometimes books go out of print. Let's remove one. - -1. Delete a book: - - ``` - - DELETE FROM book_catalog - WHERE JSON_VALUE(data, '$.title') = 'The Silent Patient'; - - ``` - -2. Verify the deletion: - - ``` - - SELECT COUNT(*) FROM book_catalog; - - ``` - -## Summary - -You've successfully created and managed a JSON collection table for a bookstore catalog. JSON collection tables are ideal for scenarios where: - -* Data structures vary significantly between records -* You need to store complex, nested information -* Schema evolution is frequent -* You're migrating from document databases to Oracle - -In the next lab, we'll explore JSON Duality views, which provide relational access to JSON data. - -## Learn More - -* [JSON Collection Tables Documentation](https://docs.oracle.com/en/database/oracle/oracle-database/23/adjsn/json-collection-tables.html) -* [SQL/JSON Functions](https://docs.oracle.com/en/database/oracle/oracle-database/23/adjsn/sql-json-functions.html) diff --git a/23aijsontest/labs/duality-views/duality-views.md b/23aijsontest/labs/duality-views/duality-views.md deleted file mode 100644 index bcaf90ac..00000000 --- a/23aijsontest/labs/duality-views/duality-views.md +++ /dev/null @@ -1,235 +0,0 @@ -# Lab 2: JSON Duality Views - -## Introduction - -Building on our bookstore example, imagine your e-commerce platform has grown. You now have existing relational tables for customer orders, inventory management, and reporting systems. However, your product catalog is stored as JSON documents for flexibility. JSON Duality views bridge this gap, allowing you to access and manipulate the same data through both JSON and relational interfaces. This ensures data consistency and lets different parts of your application use the most appropriate data model. - -Estimated Lab Time: 25 minutes - -### Objectives - -* Understand the concept of JSON Duality views -* Create a duality view over JSON collection data -* Query data through relational and JSON interfaces -* Perform updates that maintain consistency -* Learn when duality views are beneficial - -### Prerequisites - -* Completed Lab 1: JSON Collection Tables -* Access to Oracle Database 23ai with the book_catalog table from Lab 1 - -## Task 1: Set Up Relational Tables - -To demonstrate duality, let's create some relational tables that will be linked to our JSON data. - -1. Create a table for book genres: - - ``` - - CREATE TABLE genres ( - genre_id NUMBER GENERATED ALWAYS AS IDENTITY PRIMARY KEY, - genre_name VARCHAR2(50) UNIQUE NOT NULL - ); - - ``` - -2. Create a table for authors: - - ``` - - CREATE TABLE authors ( - author_id NUMBER GENERATED ALWAYS AS IDENTITY PRIMARY KEY, - author_name VARCHAR2(100) NOT NULL - ); - - ``` - -3. Insert some sample data: - - ``` - - INSERT INTO genres (genre_name) VALUES ('Romance'), ('Thriller'), ('Children'); - INSERT INTO authors (author_name) VALUES ('Jane Austen'), ('Eric Carle'); - - ``` - -## Task 2: Create a JSON Duality View - -Now we'll create a duality view that presents our JSON book catalog data through a relational interface, while maintaining the flexibility of JSON storage. - -1. Create the duality view: - - ``` - - CREATE JSON DUALITY VIEW book_catalog_dual AS - SELECT - JSON_VALUE(data, '$.title') AS title, - JSON_VALUE(data, '$.published_year') AS published_year, - JSON_VALUE(data, '$.pages') AS pages, - JSON_VALUE(data, '$.price') AS price, - JSON_VALUE(data, '$.genre') AS genre, - JSON_QUERY(data, '$.author') AS authors, - JSON_VALUE(data, '$.isbn') AS isbn - FROM book_catalog; - - ``` - - This view allows us to query the JSON data as if it were a relational table. - -## Task 3: Query Through the Duality View - -Let's explore our data using the relational interface. - -1. View all books in relational format: - - ``` - - SELECT title, genre, price, published_year - FROM book_catalog_dual; - - ``` - -2. Find books by price range: - - ``` - - SELECT title, price - FROM book_catalog_dual - WHERE price > 10; - - ``` - -3. Join with our genres table: - - ``` - - SELECT b.title, g.genre_name - FROM book_catalog_dual b - JOIN genres g ON b.genre = g.genre_name; - - ``` - -4. Access JSON-specific data through the view: - - ``` - - SELECT title, authors - FROM book_catalog_dual - WHERE JSON_EXISTS(authors, '$[0]'); - - ``` - -## Task 4: Update Data Through Duality View - -The true power of duality views is that changes made through the relational interface are automatically reflected in the underlying JSON data, and vice versa. - -1. Update a book's price through the duality view: - - ``` - - UPDATE book_catalog_dual - SET price = 12.99 - WHERE title = 'Pride and Prejudice'; - - ``` - -2. Verify the change in the original JSON table: - - ``` - - SELECT JSON_VALUE(data, '$.title') AS title, - JSON_VALUE(data, '$.price') AS price - FROM book_catalog - WHERE JSON_VALUE(data, '$.title') = 'Pride and Prejudice'; - - ``` - -3. Add a new field through JSON operations (this would be reflected in duality view queries that access it): - - ``` - - UPDATE book_catalog - SET data = JSON_TRANSFORM(data, SET '$.rating' = 4.8) - WHERE JSON_VALUE(data, '$.title') = 'The Very Hungry Caterpillar'; - - ``` - -4. Query the new field through duality view (we'd need to modify the view to include it, but for demonstration): - - ``` - - SELECT JSON_VALUE(data, '$.rating') AS rating - FROM book_catalog - WHERE JSON_VALUE(data, '$.title') = 'The Very Hungry Caterpillar'; - - ``` - -## Task 5: Insert Through Duality View - -You can also insert data through the duality view. - -1. Insert a new book: - - ``` - - INSERT INTO book_catalog_dual (title, published_year, pages, price, genre, authors, isbn) - VALUES ('1984', 1949, 328, 11.99, 'Dystopian', '["George Orwell"]', '978-0451524935'); - - ``` - -2. Verify the insertion in both views: - - ``` - - SELECT title, genre FROM book_catalog_dual WHERE title = '1984'; - - SELECT JSON_VALUE(data, '$.title'), JSON_VALUE(data, '$.genre') - FROM book_catalog WHERE JSON_VALUE(data, '$.title') = '1984'; - - ``` - -## Task 6: Explore Advanced Duality Features - -Duality views support complex relationships and constraints. - -1. Create a duality view with joins: - - ``` - - CREATE JSON DUALITY VIEW book_details AS - SELECT - b.title, - b.genre, - b.price, - g.genre_id, - JSON_QUERY(b.data, '$.awards') AS awards - FROM book_catalog b - LEFT JOIN genres g ON JSON_VALUE(b.data, '$.genre') = g.genre_name; - - ``` - -2. Query the joined view: - - ``` - - SELECT title, genre, genre_id, awards - FROM book_details; - - ``` - -## Summary - -JSON Duality views provide the best of both worlds: the flexibility of JSON document storage with the power of relational querying and constraints. They're ideal for: - -* Migrating applications gradually from document to relational models -* Supporting polyglot persistence within a single database -* Enabling different teams to work with the same data using their preferred paradigm -* Maintaining data consistency across JSON and relational interfaces - -You've now experienced both JSON Collection tables and Duality views, giving you powerful tools for modern application development with Oracle Database 23ai. - -## Learn More - -* [JSON Duality Views Documentation](https://docs.oracle.com/en/database/oracle/oracle-database/23/adjsn/json-duality-views.html) -* [Creating Duality Views](https://docs.oracle.com/en/database/oracle/oracle-database/23/adjsn/creating-json-duality-views.html) diff --git a/23aijsontest/workshops/oracle-json-23ai/index.html b/23aijsontest/workshops/oracle-json-23ai/index.html deleted file mode 100644 index e295c943..00000000 --- a/23aijsontest/workshops/oracle-json-23ai/index.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - Oracle LiveLabs - - - - - - - - - - - - - -
-
-
-
-
-
-
-
- - - - - diff --git a/23aijsontest/workshops/oracle-json-23ai/manifest.json b/23aijsontest/workshops/oracle-json-23ai/manifest.json deleted file mode 100644 index 33714439..00000000 --- a/23aijsontest/workshops/oracle-json-23ai/manifest.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "workshoptitle": "Oracle Database 23ai—JSON Support", - "help": "livelabs-help-db_us@oracle.com", - "tutorials": [ - { - "title": "Get Started", - "description": "Prerequisites for LiveLabs (Oracle-owned tenancies). The title of the lab and the Contents Menu title (the title above) match for Prerequisite lab. This lab is always first.", - "filename": "https://oracle-livelabs.github.io/common/labs/cloud-login/cloud-login-livelabs2.md" - }, - { - "title": "Introduction", - "description": "The Introduction is always second for LiveLabs. The title and contents menu title match for the Introduction.", - "filename": "../../intro/intro.md" - }, - { - "title": "Lab 1: JSON Collection Tables", - "description": "Learn how to create and use JSON Collection tables for storing and querying JSON documents in Oracle Database 23ai.", - "filename": "../../labs/collection-tables/collection-tables.md" - }, - { - "title": "Lab 2: JSON Duality Views", - "description": "Explore JSON Duality views to access the same data through both relational and JSON interfaces.", - "filename": "../../labs/duality-views/duality-views.md" - }, - { - "title": "Need Help?", - "description": "Solutions to Common Problems and Directions for Receiving Live Help", - "filename":"https://oracle-livelabs.github.io/common/labs/need-help/need-help-livelabs.md" - } - ] -}