Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

First, have a look at conceptual / physical model. All required is the SQL code AND screenshots of outputs of these queries in Oracle SQL

First, have a look at conceptual/physical model. All required is the SQL code AND screenshots of outputs of these queries in Oracle SQL Developer, but since I couldn't send the data of these tables, I just want you to write the SQL code and see all the screenshots and my descriptions in this text. Please, read carefully and make sure the queries are correct and executable:
Before extracting data, launch script below. Script creates hierarchy (unary relation) in table customer and adds data.
-----------------------------------
Alter table Customers ADD RefCust NUMBER(6);
Alter table Customers
add constraint CustRefHier
Foreign Key (RefCust)
References Customers(CUSTID);
UPDATE Customers SET RefCust=(Select custid FROM Customers where CUSTNAME='Zhang') WHERE CUSTID=(Select custid FROM Customers where CUSTNUM='133819');
UPDATE Customers SET RefCust=(Select custid FROM Customers where CUSTNAME='Zhang') WHERE CUSTID=(Select custid FROM Customers where CUSTNUM='182194');
UPDATE Customers SET RefCust=(Select custid FROM Customers where CUSTNAME='Martin') WHERE CUSTID=(Select custid FROM Customers where CUSTNUM='246754');
UPDATE Customers SET RefCust=(Select custid FROM Customers where CUSTNAME='Martin') WHERE CUSTID=(Select custid FROM Customers where CUSTNUM='285028');
UPDATE Customers SET RefCust=(Select custid FROM Customers where CUSTNAME='Martin') WHERE CUSTID=(Select custid FROM Customers where CUSTNUM='294827');
UPDATE Customers SET RefCust=(Select custid FROM Customers where CUSTNAME='Chen') WHERE CUSTID=(Select custid FROM Customers where CUSTNUM='381074');
UPDATE Customers SET RefCust=(Select custid FROM Customers where CUSTNAME='Chen') WHERE CUSTID=(Select custid FROM Customers where CUSTNUM='429292');
UPDATE Customers SET RefCust=(Select custid FROM Customers where CUSTNAME='Perez') WHERE CUSTID=(Select custid FROM Customers where CUSTNUM='482910');
UPDATE Customers SET RefCust=(Select custid FROM Customers where CUSTNAME='Perez') WHERE CUSTID=(Select custid FROM Customers where CUSTNUM='539118');
UPDATE Customers SET RefCust=(Select custid FROM Customers where CUSTNAME='Jackson') WHERE CUSTID=(Select custid FROM Customers where CUSTNUM='592937');
UPDATE Customers SET RefCust=(Select custid FROM Customers where CUSTNAME='Jackson') WHERE CUSTID=(Select custid FROM Customers where CUSTNUM='730282');
UPDATE Customers SET RefCust=(Select custid FROM Customers where CUSTNAME='Jefferson') WHERE CUSTID=(Select custid FROM Customers where CUSTNUM='876586');
UPDATE Customers SET RefCust=(Select custid FROM Customers where CUSTNAME='Jefferson') WHERE CUSTID=(Select custid FROM Customers where CUSTNUM='925820');
UPDATE Customers SET RefCust=(Select custid FROM Customers where CUSTNAME='Stewart') WHERE CUSTID=(Select custid FROM Customers where CUSTNUM='956732');
-----------------------------------------------
Extract from customers:
- names adding indent of 3 "spaces" for every next level;
- show customer level number in the hierarchy;
- show tree path from current customer up to top customer in the hierarchy;
- show only first 4 levels of the tree.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Spatial And Temporal Databases 10th International Symposium Sstd 2007 Boston Ma Usa July 2007 Proceedings Lncs 4605

Authors: Dimitris Papadias ,Donghui Zhang ,George Kollios

2007th Edition

3540735399, 978-3540735397

More Books

Students also viewed these Databases questions

Question

Evaluate 3x - x for x = -2 Answer:

Answered: 1 week ago