Question: ANY HELP WITH JASONB IN DATABASES......PLEASE.. THIS IS THE QUERY AND ANSWER THE QUESTIONS.. WHICH WILL BE REALLY HELPFUL PLEASE SOLVE A TO D PART

ANY HELP WITH JASONB IN DATABASES......PLEASE.. THIS IS THE QUERY AND ANSWER THE QUESTIONS.. WHICH WILL BE REALLY HELPFUL

PLEASE SOLVE A TO D PART

THIS IS THE FULL QUERY ON JASONB

CREATE TABLE orders ( ID serial NOT NULL PRIMARY KEY, info jsonb NOT NULL );

INSERT INTO orders (info) VALUES ('{ "customer": "John Doe", "items": {"product": "Beer","qty": 6}}');

INSERT INTO orders (info) VALUES('{ "customer": "Lily Bush", "items": {"product": "Diaper","qty": 24}}'), ('{ "customer": "Josh William", "items": {"product": "Toy Car","qty": 1}}'), ('{ "customer": "Mary Clark", "items": {"product": "Toy Train","qty": 2}}');

SELECT * FROM orders;

USING JASONB

a. Update the table so that quantity of toy car ordered by Josh William is 25.

b. Change the table so that items is an array of json objects. Each json object in the array has two fields, "qty" and "product". This change should happen for every row of the table.

c. Update the table so that there are two orders made by Josh William. Josh should also order 'Cherio'. The quantity of his order for Cherio should be 2. Do not add any new rows to the table. Instead, Josh's second order should appear in the same row as his first order.

d. Write a query that gives a table that shows only orders where qty is 2. Each row in the table should have id, customer, qty, and product as attributes. (You will need to write a subquery.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!