From e87555c249b7d53a50c80c04ef2325e40a80b8d4 Mon Sep 17 00:00:00 2001 From: Kevin Lazarz Date: Wed, 4 Sep 2024 22:32:53 +0200 Subject: [PATCH] Fix formatting WMS 11431 (#671) * Patch PAR URLs database repository Patch PAR URLs database repository * Patch part 2 - database Patch part 2 - database * Patch 3 - database Patch 3 - database * Fix database repo (outdated URLS) Fix database repo (outdated URLS) * WMS 1: Update multitenant nextGen part 1 WMS 1: Update multitenant nextGen part 1 * WMS 1: changes for nextGen Part 2 WMS 1: changes for nextGen Part 2 * WMS 1: Fix manifest for OCW24 WMS 1: Fix manifest for OCW24 * Fix formatting WMS 11431 Fix formatting WMS 11431 --- json-duality/1-create-schema/create-schema.md | 70 ++--- json-duality/2-explore-data/explore-data.md | 261 +++++++++--------- .../json-duality-views.md | 168 ++++++----- .../4-json-utilities/json-utilities.md | 135 +++++---- json-duality/5-rest-duality/rest-duality.md | 6 +- json-duality/workshops/sandbox/manifest.json | 13 +- 6 files changed, 353 insertions(+), 300 deletions(-) diff --git a/json-duality/1-create-schema/create-schema.md b/json-duality/1-create-schema/create-schema.md index 980b6aeca..7bf4b9bee 100644 --- a/json-duality/1-create-schema/create-schema.md +++ b/json-duality/1-create-schema/create-schema.md @@ -28,31 +28,31 @@ This lab assumes you have: 2. Login as the `CLASSMATE` user. To do this, Click on the drop-down arrow to the right of the `ADMIN` user and click *Sign Out* . -![showing the schema drop-down-menu](./images/lab010102a.png) + ![showing the schema drop-down-menu](./images/lab010102a.png) -At the Sign-in screen enter: + At the Sign-in screen enter: - Username: *CLASSMATE* - Password: *College2024#* + Username: *CLASSMATE* + Password: *College2024#* -and click the "Sign in" button. + and click the "Sign in" button. -![showing the sign-in screen](./images/lab010102b.png) + ![showing the sign-in screen](./images/lab010102b.png) -This will bring you to the "Database Actions Launchpad". + This will bring you to the "Database Actions Launchpad". -(If it's the first time you are accessing the Launchpad, your default homepage will be the "Development" page. If not, click the "Development" tab to display the development menu.) + (If it's the first time you are accessing the Launchpad, your default homepage will be the "Development" page. If not, click the "Development" tab to display the development menu.) -Click "SQL" in the menu on the left hand side of the screen. You will now be at the SQL Worksheet screen. + Click "SQL" in the menu on the left hand side of the screen. You will now be at the SQL Worksheet screen. -![showing the SQL drop-down-menu](./images/lab010102c.png) + ![showing the SQL drop-down-menu](./images/lab010102c.png) -We're now ready to start creating our tables. + We're now ready to start creating our tables. 3. We will start by creating a table called: `student`. -Copy and paste the following code in the SQL Worksheet pane. Click "Run Script" to execute the code. + Copy and paste the following code in the SQL Worksheet pane. Click "Run Script" to execute the code. ``` @@ -90,16 +90,16 @@ Copy and paste the following code in the SQL Worksheet pane. Click "Run Script" ![Showing the terminal](images/lab010104a.png " ") -You should see 12 rows created. + You should see 12 rows created. -Verify the contents of the table you just created by clicking the "Run Script" button- + Verify the contents of the table you just created by clicking the "Run Script" button- - ``` - - SELECT * FROM student ; - - ``` -You should see the following- + ``` + + SELECT * FROM student ; + + ``` + You should see the following: ![Showing the select student](images/lab010104b.png " ") @@ -137,17 +137,17 @@ You should see the following- ![Showing the create teacher](images/lab010106a.png " ") -You should see 8 rows inserted. + You should see 8 rows inserted. -You can also verify the contents of the table you just created by running the following- + You can also verify the contents of the table you just created by running the following- - ``` - - SELECT * FROM teacher ; - - ``` + ``` + + SELECT * FROM teacher ; + + ``` -You should see the following- + You should see the following: ![Showing the create teacher](images/lab010106b.png " ") @@ -175,7 +175,7 @@ You should see the following- ![Showing the create course](images/lab010107.png " ") -Once the `course` table is created, populate the `course` table with the following entries. + Once the `course` table is created, populate the `course` table with the following entries. ``` @@ -205,11 +205,11 @@ Once the `course` table is created, populate the `course` table with the followi ``` -You should see 11 rows inserted. + You should see 11 rows inserted. ![Showing the insert into course](images/lab010108a.png " ") -You can also verify the contents of the table you just created- + You can also verify the contents of the table you just created- ``` @@ -217,7 +217,7 @@ You can also verify the contents of the table you just created- ``` -You should see the following- + You should see the following: ![Showing the select from course](images/lab010108b.png " ") @@ -266,9 +266,9 @@ You should see the following- ``` ![Showing the insert into student course](images/lab010110a.png " ") -You should see 17 rows inserted. + You should see 17 rows inserted. -You can also verify the contents of the table you just created issuing the following command- + You can also verify the contents of the table you just created issuing the following command- ``` @@ -276,7 +276,7 @@ You can also verify the contents of the table you just created issuing the follo ``` -You should see the following- + You should see the following: ![Showing the select student course](images/lab010110b.png " ") diff --git a/json-duality/2-explore-data/explore-data.md b/json-duality/2-explore-data/explore-data.md index 6c34eea68..976c212c2 100644 --- a/json-duality/2-explore-data/explore-data.md +++ b/json-duality/2-explore-data/explore-data.md @@ -25,186 +25,199 @@ Oracle Database 23ai introduces a new JSON Schema package `dbms_json_schema` to We're now ready to describe the JSON documents for the tables we just created- -1. We can start by viewing the JSON Schema of the `student` table. Make sure to use "Run Script" to view the document pretty formated- +1. We can start by viewing the JSON Schema of the `student` table. Make sure to use "Run Script" to view the document pretty formatted: - ``` - - SELECT json_serialize(dbms_json_schema.describe('STUDENT') PRETTY) "Student"; - - ``` + ``` + + SELECT json_serialize(dbms_json_schema.describe('STUDENT') PRETTY) "Student"; + + ``` - You should see the following- - ![Showing the json-schema for student](images/lab020101.png " ") + You should see the following: + + ![Showing the json-schema for student](images/lab020101.png " ") -**NOTE:** You may have noticed we are able to use the *PRETTY* command to see the JSON document contents formatted in an easy to read format. + **NOTE:** You may have noticed we are able to use the *PRETTY* command to see the JSON document contents formatted in an easy to read format. + +2. Next we can view the JSON Schema of the `teacher` table: -2. Next we can view the JSON Schema of the `teacher` table- + ``` + + SELECT json_serialize(dbms_json_schema.describe('TEACHER') PRETTY) "Teacher"; + + ``` - ``` - - SELECT json_serialize(dbms_json_schema.describe('TEACHER') PRETTY) "Teacher"; - - ``` + You should see the following: + + ![Showing the json-schema for teacher](images/lab020102.png " ") -You should see the following- - ![Showing the json-schema for teacher](images/lab020102.png " ") + *NOTE:* Feel free to resize the window size of the "Script Output" pane to view more of the JSON document. - *NOTE:* Feel free to resize the window size of the "Script Output" pane to view more of the JSON document. +3. View the JSON Schema of the `course` table: -3. View the JSON Schema of the `course` table- + ``` + + SELECT json_serialize(dbms_json_schema.describe('COURSE') PRETTY) "Course"; + + ``` - ``` - - SELECT json_serialize(dbms_json_schema.describe('COURSE') PRETTY) "Course"; - - ``` + You should see the following: -You should see the following- - ![Showing the json-schema for course](images/lab020103.png " ") + ![Showing the json-schema for course](images/lab020103.png " ") - *NOTE:* Feel free to resize the window size of the "Script Output" pane to view more of the JSON document. + *NOTE:* Feel free to resize the window size of the "Script Output" pane to view more of the JSON document. -4. It is also possible to display the contents of just the JSON Document. We can try this with the `course` table. We can view the contents of the `course_info` document in the `course` table by issueing the following command - +4. It is also possible to display the contents of just the JSON Document. We can try this with the `course` table. We can view the contents of the `course_info` document in the `course` table by issueing the following command: - ``` - - SELECT json_serialize(course_info pretty) FROM course; - - ``` + ``` + + SELECT json_serialize(course_info pretty) FROM course; + + ``` -You should see the following- - ![Showing the json-schema for course info](images/lab020104.png " ") + You should see the following: + + ![Showing the json-schema for course info](images/lab020104.png " ") 5. We can also look at the JSON document for a specific Course: **MATH_01** - ``` - - SELECT json_serialize(course_info PRETTY) "courseInfo" - FROM classmate.course c - WHERE c.course_name = 'MATH_01' ; - - ``` + ``` + + SELECT json_serialize(course_info PRETTY) "courseInfo" + FROM classmate.course c + WHERE c.course_name = 'MATH_01' ; + + ``` + + You should see the following: -You should see the following- - ![Showing the json-schema for a single course](images/lab020105.png " ") + ![Showing the json-schema for a single course](images/lab020105.png " ") 6. We can also look at the JSON document for an individual Student: **Jerri** - ``` - - SELECT student_name, json_serialize(student_info PRETTY) "studentInfo" - FROM classmate.student s - WHERE s.student_name = 'Jerri' ; - - ``` + ``` + + SELECT student_name, json_serialize(student_info PRETTY) "studentInfo" + FROM classmate.student s + WHERE s.student_name = 'Jerri' ; + + ``` -You should see the following- - ![Showing the json-schema for a specific student](images/lab020106.png " ") + You should see the following: + + ![Showing the json-schema for a specific student](images/lab020106.png " ") 7. It is also possible to view the contents of a relational table as a JSON document with Oracle SQL. - ``` - - SELECT JSON {*} FROM classmate.student ; - - ``` + ``` + + SELECT JSON {*} FROM classmate.student ; + + ``` + + You should see the following: -You should see the following- - ![Showing json output for a student](images/lab020107.png " ") + ![Showing json output for a student](images/lab020107.png " ") 8. We can also perform a *Query-By-Example* (QBE) operation on a JSON document in Oracle. - In the next example we will see how to query the document to only view Students whose majors are in Biology or Chemistry. You can do this by running the following command- + In the next example we will see how to query the document to only view Students whose majors are in Biology or Chemistry. You can do this by running the following command- - ``` - - SELECT JSON {*} - FROM classmate.student - WHERE json_value(student_info, '$.Major') IN ('Biology', 'Chemistry'); - - ``` + ``` + + SELECT JSON {*} + FROM classmate.student + WHERE json_value(student_info, '$.Major') IN ('Biology', 'Chemistry'); + + ``` -You should see the following- - ![Showing json output for all students in Biology and Chemistry](images/lab020108.png " ") + You should see the following: -## TASK 2: Using Oracle `JSON_DATAGUIDE` + ![Showing json output for all students in Biology and Chemistry](images/lab020108.png " ") + +## Task 2: Using Oracle `JSON_DATAGUIDE` One of the benefits of using an Oracle database to store JSON collections is that it is possible to leverage other Oracle features including Oracle Machine Learning algorithms. But many of the Oracle tools require data to be in a relatinal format. To ease this requirement Oracle has a feature called `JSON_DATAGUIDE`. `JSON_DATAGUIDE` provides the ability to render the contents of a JSON document to appear as a database relational view that can then be queried using the SQL language. 1. For our first step we will create a JSON_DATAGUIDE view for the `student` table. - ``` - - DECLARE - dGuide CLOB ; - BEGIN - SELECT JSON_DATAGUIDE(student_info, DBMS_JSON.FORMAT_HIERARCHICAL) - INTO dGuide from student ; - - dbms_json.create_view('DG_AutoView', 'STUDENT', 'student_info', dGuide ); - END; - - ``` + ``` + + DECLARE + dGuide CLOB ; + BEGIN + SELECT JSON_DATAGUIDE(student_info, DBMS_JSON.FORMAT_HIERARCHICAL) + INTO dGuide from student ; + + dbms_json.create_view('DG_AutoView', 'STUDENT', 'student_info', dGuide ); + END; + + ``` + + You should see the following: -You should see the following- - ![Showing compilation of JSON_DATAGUIDE](images/lab020201.png " ") + ![Showing compilation of JSON_DATAGUIDE](images/lab020201.png " ") 2. You can describe the view to see the JSON document keys listed as columns. - ``` - - DESC DG_AutoView - - ``` + ``` + + DESC DG_AutoView + + ``` -You should see the following- - ![Showing describe of student dataguide view](images/lab020202.png " ") + You should see the following: -**NOTE:** The column names for the document keys are case-sensitive, so you will need to take that into account when querying the view. + ![Showing describe of student dataguide view](images/lab020202.png " ") -A regular SQL query can display the contents of the view for us. + **NOTE:** The column names for the document keys are case-sensitive, so you will need to take that into account when querying the view. - ``` - - SELECT * FROM DG_AutoView ORDER BY 1 ; - - ``` + A regular SQL query can display the contents of the view for us. -You should see the following- - ![Showing select from dataguide view](images/lab020203.png " ") + ``` + + SELECT * FROM DG_AutoView ORDER BY 1 ; + + ``` -When querying the view, you will need to enclose the case-sensitive columns in double quotes. + You should see the following: - ``` - - SELECT student_id, "lastName", "Major" - FROM DG_AutoView ORDER BY 1 ; - - ``` + ![Showing select from dataguide view](images/lab020203.png " ") -You should see the following- - ![Showing select from dataguide view](images/lab020204.png " ") + When querying the view, you will need to enclose the case-sensitive columns in double quotes. -Let's see what happens if we try to update the document using the view. - - ``` - - UPDATE DG_AutoView - SET "Major" = 'Law' - WHERE student_id = 1015 ; - - ``` - -You should see the following- - ![Showing DML on dataguide view](images/lab020205.png " ") - -**NOTE** This operation is expected to FAIL, as `DG_AUTOVIEW` is a view and as such it's not updateable. This restriction will be addressed in the next lab where we will be using Oracle Database 23ai JSON-Relational Duality Views. + ``` + + SELECT student_id, "lastName", "Major" + FROM DG_AutoView ORDER BY 1 ; + + ``` + + You should see the following: + + ![Showing select from dataguide view](images/lab020204.png " ") + + Let's see what happens if we try to update the document using the view. + + ``` + + UPDATE DG_AutoView + SET "Major" = 'Law' + WHERE student_id = 1015 ; + + ``` + + You should see the following + + ![Showing DML on dataguide view](images/lab020205.png " ") + + **NOTE** This operation is expected to FAIL, as `DG_AUTOVIEW` is a view and as such it's not updateable. This restriction will be addressed in the next lab where we will be using Oracle Database 23ai JSON-Relational Duality Views. Congratulations! You have finished this lab. You may now **proceed to the next lab** diff --git a/json-duality/3-json-duality-views/json-duality-views.md b/json-duality/3-json-duality-views/json-duality-views.md index 696084c78..a6d79c1e7 100644 --- a/json-duality/3-json-duality-views/json-duality-views.md +++ b/json-duality/3-json-duality-views/json-duality-views.md @@ -31,41 +31,41 @@ This lab assumes you have: 1. Four our first step we will create a JSON Relational Duality View. Copy and run the following code- - ``` - - CREATE OR REPLACE JSON RELATIONAL DUALITY VIEW student_schedule AS - SELECT JSON {'_id' : sc.scid, - 'student' : - (SELECT JSON {'studentId' : s.student_id, - 'studentName' : s.student_name, - 'studentInfo' : s.student_info } - FROM classmate.student s WITH NOINSERT UPDATE NODELETE - WHERE sc.student_id = s.student_id - ), - 'schedule' : - (SELECT JSON {'courseId' : c.course_id, - 'courseName' : c.course_name, - 'courseRoom' : c.room, - 'courseTime' : c.time, - 'teacher' : - (SELECT JSON { 'teacherName' : t.teacher_name, - 'teacherId' : t.teacher_id } - FROM classmate.teacher t WITH NOINSERT UPDATE NODELETE - WHERE c.teacher_id = t.teacher_id) - } - FROM classmate.course c WITH NOINSERT UPDATE NODELETE - WHERE sc.course_id = c.course_id - ) - } - FROM classmate.student_courses sc WITH INSERT UPDATE DELETE ; - - ``` - -You should see the following- - ![Showing create duality view](images/lab030101.png " ") - -NOTE: You may have noticed that we have -2. Let's take a look at the Duality View we just created- + ``` + + CREATE OR REPLACE JSON RELATIONAL DUALITY VIEW student_schedule AS + SELECT JSON {'_id' : sc.scid, + 'student' : + (SELECT JSON {'studentId' : s.student_id, + 'studentName' : s.student_name, + 'studentInfo' : s.student_info } + FROM classmate.student s WITH NOINSERT UPDATE NODELETE + WHERE sc.student_id = s.student_id + ), + 'schedule' : + (SELECT JSON {'courseId' : c.course_id, + 'courseName' : c.course_name, + 'courseRoom' : c.room, + 'courseTime' : c.time, + 'teacher' : + (SELECT JSON { 'teacherName' : t.teacher_name, + 'teacherId' : t.teacher_id } + FROM classmate.teacher t WITH NOINSERT UPDATE NODELETE + WHERE c.teacher_id = t.teacher_id) + } + FROM classmate.course c WITH NOINSERT UPDATE NODELETE + WHERE sc.course_id = c.course_id + ) + } + FROM classmate.student_courses sc WITH INSERT UPDATE DELETE ; + + ``` + + You should see the following: + + ![Showing create duality view](images/lab030101.png " ") + +2. Let's take a look at the Duality View we just created: ``` @@ -73,10 +73,11 @@ NOTE: You may have noticed that we have ``` -You should see the following- - ![Showing describe duality view](images/lab030102.png " ") + You should see the following + + ![Showing describe duality view](images/lab030102.png " ") -You will notice when describing the `STUDENT_SCHEDULE` that it contains a single JSON document called DATA. + You will notice when describing the `STUDENT_SCHEDULE` that it contains a single JSON document called DATA. 3. As `STUDENT_SCHEDULE` is a JSON Document, we can use the `DBMS_JSON_SCHEMA.DESCRIBE` package to view the Duality View schema- @@ -87,7 +88,8 @@ You will notice when describing the `STUDENT_SCHEDULE` that it contains a single ``` -You should see the following- + You should see the following: + ![Showing describe view](images/lab030103.png " ") @@ -99,7 +101,8 @@ You should see the following- ``` -You should see the following- + You should see the following: + ![Showing describe duality view](images/lab030104.png " ") @@ -111,7 +114,8 @@ You should see the following- ``` -You should see the following- + You should see the following: + ![Showing describe duality view](images/lab030105.png " ") @@ -124,7 +128,8 @@ You should see the following- ``` -You should see the following- + You should see the following: + ![Showing select from duality view](images/lab030106.png " ") @@ -138,12 +143,13 @@ You should see the following- ``` -You should see the following- + You should see the following: + ![Showing qbe on duality view](images/lab030107.png " ") -**NOTE:** You should see 3 rows returned. + **NOTE:** You should see 3 rows returned. -8. We can also query `STUDENT_SCHEDULE` to display the schedule for a specific Teacher: "Adam" - +8. We can also query `STUDENT_SCHEDULE` to display the schedule for a specific Teacher: "Adam" : ``` @@ -153,10 +159,11 @@ You should see the following- ``` -You should see the following- + You should see the following: + ![Showing qbe on duality view](images/lab030108.png " ") -*NOTE: This query does not return any rows and it incorrectly displays: "No rows selected"* + *NOTE: This query does not return any rows and it incorrectly displays: "No rows selected"* 9. The reason there are no rows returned is that the query is incorrect. The "Teacher" information is stored in an underlying table called `TEACHER`. In order to see the `STUDENT_SCHEDULE` for a specific Teacher we need to use the following query- @@ -169,12 +176,13 @@ You should see the following- ``` -You should see the following- + You should see the following: + ![Showing qbe on duality view](images/lab030109.png " ") -This time you will see 8 rows returned. + This time you will see 8 rows returned. -While this approach solves our problem, and could be useful in storing a nested document or array, it is inconvenient and tedious when all we are looking for is information about the course. To solve this issue we can use the **UNNEST** parameter which will promote the elements from the `TEACHER` table to be in-line with the rest of our course information. We will see how to do this in the next Task. + While this approach solves our problem, and could be useful in storing a nested document or array, it is inconvenient and tedious when all we are looking for is information about the course. To solve this issue we can use the **UNNEST** parameter which will promote the elements from the `TEACHER` table to be in-line with the rest of our course information. We will see how to do this in the next Task. ## Task 2: Create a JSON Duality View with UNNEST @@ -211,10 +219,11 @@ While this approach solves our problem, and could be useful in storing a nested ``` -You should see the following- + You should see the following: + ![Showing unnest create duality view](images/lab030201.png " ") -**NOTE:** Notice the UNNEST parameter when selecting the Teacher information. + **NOTE:** Notice the UNNEST parameter when selecting the Teacher information. 2. Before we run any queries against the new version of the `STUDENT_SCHEDULE`, we should first take a look at how it has changed. Pay special attention to the `TEACHER` information- @@ -224,13 +233,14 @@ You should see the following- ``` -You should see the following- + You should see the following: + ![Showing describe duality view](images/lab030202.png " ") - **NOTE:** You should notice that the "teacherId" and "teacherName" are now at the same level as the "courseId" and "courseName". + **NOTE:** You should notice that the "teacherId" and "teacherName" are now at the same level as the "courseId" and "courseName". -3. Now that we have recreated the `STUDENT_SCHEDULE`, let's re-run our previous queries to see how the UNNEST parameter affects the output- +3. Now that we have recreated the `STUDENT_SCHEDULE`, let's re-run our previous queries to see how the UNNEST parameter affects the output: ``` @@ -240,10 +250,11 @@ You should see the following- ``` -You should see the following- + You should see the following: + ![Showing describe duality view](images/lab030203.png " ") -**NOTE:** You should see 3 rows returned. + **NOTE:** You should see 3 rows returned. 4. Let's revisit looking for schedules for classes for a given Teacher. This time we'll use the query format that returned no rows- @@ -256,12 +267,13 @@ You should see the following- ``` -You should see the following- + You should see the following: + ![Showing describe duality view](images/lab030204.png " ") -This time we are able to see the teacher information without the need to prefix the `teacherName` with the `teacher`. + This time we are able to see the teacher information without the need to prefix the `teacherName` with the `teacher`. -Feel free to try some other queries. + Feel free to try some other queries. ## Task 3: Perform insert and update operations on Duality Views via the SQL base tables @@ -282,7 +294,8 @@ For our first scenario let's see how the `STUDENT_SCHEDULE` is affected when we ``` -You should see the following- + You should see the following: + ![Showing select from duality view](images/lab030301.png " ") @@ -294,7 +307,8 @@ You should see the following- ``` -You should see the following- + You should see the following: + ![Showing update from duality view](images/lab030302.png " ") @@ -308,11 +322,12 @@ You should see the following- ``` -You should see the following- + You should see the following: + ![Showing select from duality view](images/lab030303.png " ") -Feel free to try some other queries. + Feel free to try some other queries. ## Task 4: Perform insert and update operations on Duality Views directly. @@ -337,10 +352,11 @@ In this task, we will see what happens when we add a new Student into the JSON d ``` - You should see the following- + You should see the following: + ![Showing select from duality view](images/lab030401a.png " ") -**NOTE:** You should see no rows returned from this query. We're running this query to confirm that Jane is not enrolled in any existing courses, so there's no entries in the student_schedule. + **NOTE:** You should see no rows returned from this query. We're running this query to confirm that Jane is not enrolled in any existing courses, so there's no entries in the student_schedule. b. Also take a look at the underlying tables: @@ -353,10 +369,11 @@ In this task, we will see what happens when we add a new Student into the JSON d ``` - You should see the following- + You should see the following: + ![Showing select from duality view](images/lab030401b.png " ") -**NOTE:** For this code, we see a row returned for the `student` table as *Jane* is a existing student. However we see no rows returned for the `student_schedule` as *Jane* is not yet enrolled in any courses. + **NOTE:** For this code, we see a row returned for the `student` table as *Jane* is a existing student. However we see no rows returned for the `student_schedule` as *Jane* is not yet enrolled in any courses. 2. Once you've established that there are no entries for the new Student, we can insert the student into the JSON Document- @@ -376,7 +393,8 @@ In this task, we will see what happens when we add a new Student into the JSON d ``` -You should see the following- + You should see the following: + ![Showing insert into duality view](images/lab030402.png " ") @@ -396,10 +414,11 @@ You should see the following- ``` - This time you should see the following- + This time you should see the following: + ![Showing insert into duality view](images/lab030403a.png " ") -**NOTE:** You will need to scroll up in the results pane to see the output for both statements. Each statement now returns a single row. + **NOTE:** You will need to scroll up in the results pane to see the output for both statements. Each statement now returns a single row. b. Also take a look at the underlying tables: @@ -411,13 +430,14 @@ You should see the following- ``` - This time you should see the following- + This time you should see the following: + ![Showing insert into duality view](images/lab030403b.png " ") -Feel free to try some other updates. + Feel free to try some other updates. -Congratulations! You have finished this lab. You may now **proceed to the next lab** + Congratulations! You have finished this lab. You may now **proceed to the next lab** ## Learn More diff --git a/json-duality/4-json-utilities/json-utilities.md b/json-duality/4-json-utilities/json-utilities.md index db1bae141..0d8b7c3a1 100644 --- a/json-duality/4-json-utilities/json-utilities.md +++ b/json-duality/4-json-utilities/json-utilities.md @@ -40,20 +40,21 @@ Oracle Database 23ai provides a number of dictionary views to display the metada ``` -You should see the following- + You should see the following: + ![Showing all_json_duality_views](images/lab040101.png " ") -**NOTE:** If you scroll to the right of the Script Output pane you can see the JSON schema for the document. Also at the right end of the output is a column with the status of the view. + **NOTE:** If you scroll to the right of the Script Output pane you can see the JSON schema for the document. Also at the right end of the output is a column with the status of the view. -The `ALL_JSON_DUALITY_VIEWS` view displays: -- the Owner and Name of the Duality View -- the Owner and Name of the underlying Root table -- information about the operations permitted on the Daulity View -- whether the Duality View is Read Only -- JSON Schema information for the Duality View -- the status or validity of the Duality View + The `ALL_JSON_DUALITY_VIEWS` view displays: + - the Owner and Name of the Duality View + - the Owner and Name of the underlying Root table + - information about the operations permitted on the Daulity View + - whether the Duality View is Read Only + - JSON Schema information for the Duality View + - the status or validity of the Duality View -[More information on ALL\_JSON\_DUALITY\_VIEWS is available here.](https://docs.oracle.com/en/database/oracle/oracle-database/23/refrn/ALL_JSON_DUALITY_VIEWS.html) + [More information on ALL\_JSON\_DUALITY\_VIEWS is available here.](https://docs.oracle.com/en/database/oracle/oracle-database/23/refrn/ALL_JSON_DUALITY_VIEWS.html) 2. For our next query, we will drill one step deeper and see a listing of all Duality Views and the underlying tables that the Duality View maps to. Run the following query- @@ -64,20 +65,21 @@ The `ALL_JSON_DUALITY_VIEWS` view displays: ``` -You should see the following- + You should see the following: + ![Showing all_duality_view_tabs view](images/lab040102.png " ") -The `ALL_JSON_DUALITY_VIEW_TABS` view displays: -- the Owner and Name of the Duality View -- the Owner and Name of each of the underlying Base tables -- the SQL expression from the where clause applied to the Base tables to create the Duality View -- information about the operations permitted on the Duality View -- whether the Duality View is Read Only -- the parent of table, if the table is child table -- the relationship of the table to the parent table - in this case *singleton* means the child table is the target of an inner join + The `ALL_JSON_DUALITY_VIEW_TABS` view displays: + - the Owner and Name of the Duality View + - the Owner and Name of each of the underlying Base tables + - the SQL expression from the where clause applied to the Base tables to create the Duality View + - information about the operations permitted on the Duality View + - whether the Duality View is Read Only + - the parent of table, if the table is child table + - the relationship of the table to the parent table - in this case *singleton* means the child table is the target of an inner join -[More information on ALL\_JSON\_DUALITY\_VIEW\_TABS is available here.](https://docs.oracle.com/en/database/oracle/oracle-database/23/refrn/ALL_JSON_DUALITY_VIEW_TABS.html) + [More information on ALL\_JSON\_DUALITY\_VIEW\_TABS is available here.](https://docs.oracle.com/en/database/oracle/oracle-database/23/refrn/ALL_JSON_DUALITY_VIEW_TABS.html) 3. We can also see a listing of all Duality Views and the underlying tables and columns that the Duality View maps to. Run the following query- @@ -88,23 +90,24 @@ The `ALL_JSON_DUALITY_VIEW_TABS` view displays: ``` -You should see the following- + You should see the following: + ![Showing all_duality_view_tab_cols view](images/lab040103.png " ") -The `ALL_JSON_DUALITY_VIEW_TAB_COLS` view displays: -- the Owner and Name of the Duality View -- the Owner and Name of each of the underlying base tables -- whether the base table is the Root (or top-most ) table of the Duality View (binary value) -- numeric value to identify the table in the Duality View -- source column name, datatype and length -- JSON key name being mapped to the column -- information about the operations permitted on the Duality View -- whether the column is read-only, generated or hidden -- whether the column is part of a primary-key -- position of the column in an ETAG, if it is part of an ETAG + The `ALL_JSON_DUALITY_VIEW_TAB_COLS` view displays: + - the Owner and Name of the Duality View + - the Owner and Name of each of the underlying base tables + - whether the base table is the Root (or top-most ) table of the Duality View (binary value) + - numeric value to identify the table in the Duality View + - source column name, datatype and length + - JSON key name being mapped to the column + - information about the operations permitted on the Duality View + - whether the column is read-only, generated or hidden + - whether the column is part of a primary-key + - position of the column in an ETAG, if it is part of an ETAG -[More information on ALL\_JSON\_DUALITY\_VIEW\_TAB\_COLS is available here.](https://docs.oracle.com/en/database/oracle/oracle-database/23/refrn/ALL_JSON_DUALITY_VIEW_TAB_COLS.html) + [More information on ALL\_JSON\_DUALITY\_VIEW\_TAB\_COLS is available here.](https://docs.oracle.com/en/database/oracle/oracle-database/23/refrn/ALL_JSON_DUALITY_VIEW_TAB_COLS.html) 4. The final dictionary view we'll look at in this lab provides information about the links associated with the base tables for the specified Duality Views. Run the following query- @@ -115,25 +118,26 @@ The `ALL_JSON_DUALITY_VIEW_TAB_COLS` view displays: ``` -You should see the following- + You should see the following: + ![Showing all_duality_view_links view](images/lab040104.png " ") -The `ALL_JSON_DUALITY_VIEW_TAB_LINKS` view displays: -- the Owner and Name of the Duality View -- the Owner and Name of each of the underlying "parent" base tables -- the Owner and Name of each of the underlying "child" base tables -- the column mappings between the parent and child tables -- the type of join in use for the parent-child relationship -- the name of the JSON key associated with the link -- JSON key name being mapped to the column -- information about the operations permitted on the Duality View -- whether the column is read-only, generated or hidden -- whether the column is part of a primary-key -- position of the column in an ETAG, if it is part of an ETAG + The `ALL_JSON_DUALITY_VIEW_TAB_LINKS` view displays: + - the Owner and Name of the Duality View + - the Owner and Name of each of the underlying "parent" base tables + - the Owner and Name of each of the underlying "child" base tables + - the column mappings between the parent and child tables + - the type of join in use for the parent-child relationship + - the name of the JSON key associated with the link + - JSON key name being mapped to the column + - information about the operations permitted on the Duality View + - whether the column is read-only, generated or hidden + - whether the column is part of a primary-key + - position of the column in an ETAG, if it is part of an ETAG -[More information on ALL\_JSON\_DUALITY\_VIEW\_TAB\_LINKS is available here.](https://docs.oracle.com/en/database/oracle/oracle-database/23/refrn/ALL_JSON_DUALITY_VIEW_LINKS.html) + [More information on ALL\_JSON\_DUALITY\_VIEW\_TAB\_LINKS is available here.](https://docs.oracle.com/en/database/oracle/oracle-database/23/refrn/ALL_JSON_DUALITY_VIEW_LINKS.html) -Feel free to run some additional queries of your own. + Feel free to run some additional queries of your own. ## Task 2: Create a JSON Duality View using the JSON-To-Duality Migrator. @@ -182,7 +186,8 @@ To keep things simple, we are going to perform the whole process using the *infe ``` -You should see the following- + You should see the following: + ![Showing create duality views](images/lab040201.png " ") @@ -196,7 +201,8 @@ You should see the following- ``` - You should see the following- + You should see the following: + ![Showing data in course_duality view](images/lab040202a.png " ") @@ -208,7 +214,8 @@ You should see the following- ``` - You should see the following- + You should see the following: + ![Showing data student_duality view](images/lab040202b.png " ") @@ -220,10 +227,11 @@ You should see the following- ``` -You should see the following- + You should see the following: + ![Showing contents of teacher_duality view](images/lab040202c.png " ") -**NOTE:** You should notice a couple of things about the Duality Views that were created, first of all the views only contain the JSON document from each of the tables: `course_info`, `student_info` and `teacher_info`. Also, the key or **\_ID** column of the JSON Duality View is the first field of the Document. + **NOTE:** You should notice a couple of things about the Duality Views that were created, first of all the views only contain the JSON document from each of the tables: `course_info`, `student_info` and `teacher_info`. Also, the key or **\_ID** column of the JSON Duality View is the first field of the Document. 3. We can also describe the Duality Views- @@ -233,7 +241,8 @@ You should see the following- ``` -You should see the following- + You should see the following: + ![Showing student_duality view](images/lab040203.png " ") @@ -245,7 +254,8 @@ You should see the following- ``` -You should see the following- + You should see the following: + ![Showing teacher_duality view](images/lab040204.png " ") @@ -258,7 +268,8 @@ You should see the following- ``` -You should see the following- + You should see the following: + ![Showing teacher_duality view](images/lab040205.png " ") @@ -272,10 +283,11 @@ You should see the following- ``` -You should see the following- + You should see the following: + ![Showing all_json_duality_view_tab_cols view](images/lab040206.png " ") -**Note:** Notice the columns that have been applied as the **_id** key for these Duality Views. Also notice the JSON documents contain Flexfields too. You can find out more about the Flex columns in chapter 7 of the JSON-Relational Duality Developers Guide linked in the *Learn More* section at the bottom of the lab. + **Note:** Notice the columns that have been applied as the **_id** key for these Duality Views. Also notice the JSON documents contain Flexfields too. You can find out more about the Flex columns in chapter 7 of the JSON-Relational Duality Developers Guide linked in the *Learn More* section at the bottom of the lab. 7. Operations on the Duality Views created with the JSON Migrator tool are similar to other Duality Views in that we can even perform *Query-By-Example* (QBE) operations. For example, we can display just the details for a Teacher with a lastname of: "Ansell"- @@ -288,13 +300,14 @@ You should see the following- ``` -You should see the following- + You should see the following: + ![Showing teacher_duality view](images/lab040207.png " ") -Feel free to try some other queries, including operations from the previous lab. + Feel free to try some other queries, including operations from the previous lab. -Congratulations! You have finished this lab. You may now **proceed to the next lab** + Congratulations! You have finished this lab. You may now **proceed to the next lab** ## Learn More diff --git a/json-duality/5-rest-duality/rest-duality.md b/json-duality/5-rest-duality/rest-duality.md index 6370de744..9c0e2f1a5 100644 --- a/json-duality/5-rest-duality/rest-duality.md +++ b/json-duality/5-rest-duality/rest-duality.md @@ -38,10 +38,12 @@ The Oracle Autonomous Database Actions | SQL tool makes it very easy to REST-ena ![showing the views drop-down](./images/lab050101b.png) 2. Right click on the `STUDENT_SCHEDULE`, hover the mouse over **REST** and click **Enable** if it isn't already enabled. + If it is already enabled, it will say Disable... instead. + If you see Disable... you don't have to do anything and can Skip ahead to Step number 5. -NOTE: If you are running macOS, you may need to press the *control-key* while clicking the name of the view for the side panel to appear. + **NOTE**: If you are running macOS, you may need to press the *control-key* while clicking the name of the view for the side panel to appear. ![showing the REST pop-up menu](./images/lab050102.png) @@ -73,7 +75,7 @@ NOTE: If you are running macOS, you may need to press the *control-key* while cl ``` ![showing the sql time to add the PL sql above](./images/lab050104a.png " ") -After the script completes running, click the **refresh-ICON** and you should see the following icon appear alongside the `STUDENT_DUALITY` view. + After the script completes running, click the **refresh-ICON** and you should see the following icon appear alongside the `STUDENT_DUALITY` view. ![showing the refresh ICON to update the REST setting](./images/lab050104b.png " ") diff --git a/json-duality/workshops/sandbox/manifest.json b/json-duality/workshops/sandbox/manifest.json index 28b53211c..9998d7cb1 100644 --- a/json-duality/workshops/sandbox/manifest.json +++ b/json-duality/workshops/sandbox/manifest.json @@ -1,7 +1,12 @@ { "workshoptitle": "Work with JSON Relational Duality Views in Oracle Database 23ai", - "help": "livelabs-help-db_us@oracle.com", - "tutorials": [ + "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": "This is an introduction to Oracle Database 23ai.", @@ -41,7 +46,7 @@ { "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" + "filename": "https://oracle-livelabs.github.io/common/labs/need-help/need-help-livelabs.md" } ] -} +} \ No newline at end of file