Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

** Edited Q: regarding tables can i we do in oracle sql?? Yes, Oracle SQL should work! Database management/SQL question (Scroll down for the SPJDatabase)

** Edited Q: "regarding tables can i we do in oracle sql??"

Yes, Oracle SQL should work!

Database management/SQL question (Scroll down for the SPJDatabase)

image text in transcribed

if exists(Select * from sys.databases where name = 'spjdatabase') Create DATABASE spjdatabase GO USE spjdatabase

CREATE TABLE j ( jno varchar(20), jname varchar(20), city varchar(20) )

CREATE TABLE p ( pno varchar(20), pname varchar(20), color varchar(20), pweight int(11), city varchar(20) )

CREATE TABLE s ( sno varchar(20), sname varchar(20), sstatus int(11), city varchar(20) )

CREATE TABLE spj ( sno varchar(20), pno varchar(20), jno varchar(20), qty int(11) )

INSERT INTO spjdatabase.s (sno, sname, sstatus, city) VALUES ('S1', 'Smith', '20', 'London'), ('S2', 'Jones', '10', 'Paris'), ('S3', 'Blake', '30', 'Paris'), ('S4', 'Clark', '20', 'Lodon'), ('S5', 'Adams', '30', 'Athens')

INSERT INTO spjdatabase.p (pno, pname, color, pweight, city) VALUES ('P1', 'Nut', 'Red', '12', 'London'), ('P2', 'Bold', 'Green', '17', 'Paris'), ('P3', 'Screw', 'Blue', '17', 'Rome'), ('P4', 'Screw', 'Red', '14', 'London'), ('P5', 'Cam', 'Blue', '12', 'Paris'), ('P6', 'Cog', 'Red', '19', 'London')

INSERT INTO spjdatabase.j (jno, jname, city) VALUES ('J1', 'Sorter', 'Paris'), ('J2', 'Punch', 'Rome'), ('J3', 'Reader', 'Athens'), ('J4', 'Console', 'Athens'), ('J5', 'Collator', 'London'), ('J6', 'Terminal', 'Oslo'), ('J7', 'Tape', 'London')

INSERT INTO spjdatabase.spj (sno, pno, jno, qty) VALUES ('S1', 'P1', 'J1', '200'), ('S1', 'P1', 'J4', '700'), ('S2', 'P3', 'J1', '400'), ('S2', 'P3', 'J2', '200'), ('S2', 'P3', 'J3', '200'), ('S2', 'P3', 'J4', '500'), ('S2', 'P3', 'J5', '600'), ('S2', 'P3', 'J6', '400'), ('S2', 'P3', 'J7', '800'), ('S2', 'P5', 'J2', '100'), ('S3', 'P3', 'J1', '200'), ('S3', 'P4', 'J2', '500'), ('S4', 'P5', 'J3', '300'), ('S4', 'P5', 'J7', '300'), ('S5', 'P2', 'J2', '200'), ('S5', 'P2', 'J4', '100'), ('S5', 'P5', 'J5', '500'), ('S5', 'P5', 'J7', '100'), ('S5', 'P6', 'J2', '200'), ('S5', 'P1', 'J4', '100'), ('S5', 'P3', 'J4', '200'), ('S5', 'P4', 'J4', '800'), ('S5', 'P5', 'J4', '400'), ('S5', 'P6', 'J4', '500')

-- change in the column names

SELECT sno AS Sno, sname AS SNAME, sstatus AS SSTATUS, city AS CITY FROM S;

SELECT pno AS Pno, pname AS PNAME, color AS COLOR, pweight AS PWEIGHT, city AS CITY FROM P;

SELECT jno AS Jno, jname AS JNAME, city AS CITY FROM J;

SELECT sno AS Sno, pno AS Pno, jno AS Jno, qty AS QTY FROM SPJ;

Write an ANSI SQL script to answer the following questions in the SPJDatabase you created. Do not tailor your answers to the instance implemented. You must use the information and techniques described in class. Name your script YourLastNameHWNo7.sql. Make sure you have comments at the top of your script that includes your name. I will test your script on my computer. Do not create the tables or the database in your script. Remember to place Use SPJDatabase at the top of your script. You will copy you script onto my computer at the beginning of class. You will also turn in a paper copy of your script. If you have multiple pages you must have your name on each page and all corner. You must write your query for the users! Before each query you must put pages stapled together in the upper left hand Selcct 1 as Question l Select 2 as Question2 Select 3 as Question3 The SQJDatabase is described as: suppliers-parts-jobs database S table is the set of all suppliers P table is the set of all parts J table is the set of all jobs, work projects SPJ table is the set of all suppliers who supply the respective parts to the respective jobs in the quantity listed. 1. Get all supplier-number/part-number/project-number triples such that the indicated supplier, part, and project are all colocated. 2. Get all supplier-number/part-number/project-number triples such that the indicated supplier part, and project are not all colocated. 3. Get all supplier-number/part-number/project-number triples such that no two of the indicated supplier, part, and project are colocated. 4. Get part numbers for parts supplied by a supplier in London. 5. Get part numbers for parts supplied by a supplier in London to a project in London

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

Step: 3

blur-text-image

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

Database Design Application Development And Administration

Authors: Michael V. Mannino

3rd Edition

0071107010, 978-0071107013

More Books

Students also viewed these Databases questions