(1) Use a single SQL statement to create a relational table and to load into the table all information about the orders submitted in 1996 or in 1998 by the customers located in Paris or in London or in Madrid. Next, enforce the appropriate consistency constraints on the new table. (2) Create a new relational table to store information about the company names of all suppliers and the total number of products supplied by each supplier. Enforce, the appropriate consistency constraints on the new table. Next, copy into the new table information about the company names of all suppliers and the total number of products supplied by each supplier. (3) Add to a relational table EMPLOYEE information about the total number of orders handled by each employee. Note, that if an employee handled no orders then for such employee the total number of orders must be set to zero. Enforce the appropriate consistency constraints on a relational table EMPLOYEE. (4) Delete from the database information about all suppliers located in USA. Information about all products supplied by the suppliers located in USA must remain in the database. You are not allowed to drop and/or to suspend any referential integrity constraints and you must modify one of NULL/NOT NULL consistency constraints. (5) Insert into a file solution1.sql implementation of the following query as SELECT statement with WITH clause. Find all orders such that a value of each order is greater than an average value of all orders submitted so far. List in each line of output an order identifier, a total value of an order, and an average value of all orders. The results must be sorted in the descending order of a total value of each order. A total value of an order must be computed as the summation of unit price * quantity over all items included in the order. The query must be implemented as a sequence of subquery definitions following WITH keyword and ended with the final SELECT. (i) The first subquery definition must find a total value of each order together with an order identifier (attribute order_id). (ii) The second subquery definition must find an average value of all orders. (iii) The third subquery definition must find all orders and their values such that value of each order is greater than an average value of all orders. (iv) The final SELECT statement must extend the results of subquery definition (iii) with a column average_value that contains an average value of all orders and it must sort the results in descending order of a total value of each order.
1. CREATE TABLE ORDER (ORDER_ID VARCHAR(10) NOT NULL,
CUSTOMER_ID VARCHAR(7) NOT NULL,
ORDER_DATE DATE NOT NULL,
COUNTRY VARCHAR(50) NOT NULL,
CITY VARCHAR(25) NOT NULL,
PRIMARY KEY(ORDER_ID),
CHECK (ORDER_DATE IN ('%1996','%1998') AND CITY IN ('PARIS','LONDON','MADRID')
);
LOAD DATA INFILE 'ORDERS.csv'
INTO TABLE ORDER
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS;
2. CREATE TABLE SUPPLIERS ( SUPPLIERS_NAME VARCHAR(10) NOT NULL'
SUPPLIER_ID INT(10) NOT NULL,
COMPANY_NAME VARCHAR(50) NOT NULL,
PRODUCTS_SUPPLIED INT(100),
COUNTY CHAR(15),
COUNTRY CHAR(10),
PRIMARY KEY (SUPPLIER_ID));
LOAD DATA INFILE 'SUPPLIER_RECORD.csv'
INTO TABLE SUPPLIERS
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 ROWS;
3. CREATE TABLE EMPLOYEES (
EMP_ID CHAR(9) NOT NULL,
SEX CHAR,
ORDERS_HANDLED INT(50) NOT NULL;
PRIMARY KEY (EMP_ID));
4. DELETE FROM SUPPLIERS WHERE COUNTRY=='USA';
(1) Use a single SQL statement to create a relational table and to load into the...
database and sql problme
THE QUESTIONS 3, 4,5 and 6 REFER TO THE RELATIONAL TABLES LISTED BELOW CREATE TABLE Department ( DECIMAL(5) VARCHAR(30) CHAR(5) DATE NOT NULL NOT NULL NOT NULL * Department number /*Department name * Department manager number */ /Manager start date DNumber DName Manager MSDate CONSTRAINT Department_PK PRIMARY KEY(DNumber) CONSTRAINT Department_CK UNIQUE(DName) CREATE TABLE DeptLocation DECIMAL(5) VARCHAR(50) NOT NULL NOT NULL DNumber * Department number */ * Department location */ Address CONSTRAINT DeptLocation_PK PRIMARY KEY(DNumber, Address) CONSTRAINT...
An objective of this task is to implement SQL script that verifies the following logical consistency constraint imposed on the contents of a sample database. "All orders submitted after 30 April 2019 must not include discontinued products" Download a file solution1.sql and insert into the file the implementations of the following actions. (1) First, the script inserts into a sample database information about a new order submitted today that includes two products. One of the products is discontinued while the...
Questions in this part ask you to write SQL queriesthat would retrieve certain information from the tables. For each question, write the SQL query that would display the information asked by the question. Display information about parts that have their weights greater than the average weight of all parts. PNO PNAME P2 BOLT P3 SCREW Find supplier numbers who supply any screws (i.e., such that the part name is ‘screw’). The constraint is that you may not use any join or...
SQL query: Write a SQL statement using the employees table and retrieve employees whose monthly salary (including their commission) is greater or equal to 5,000 but less than or equal to 17,000 (we are assuming the salary on the table is monthly). In other words, if their monthly salary was 1000 and their commission was .2, their total monthly salary would be 1200 and given the criteria above this instance would not be selected. Please display the full name of...
Consider the following relational schemas: Employee (eid: integer, ename: string, Job_title: string, Years_of_experience: integer) Project (pid: integer, pname: string, parea: string, mid: integer, budget: integer) Works_on (eid: integer, pid: integer) Manger (mid: integer, mname: string, deptid: integer) The meaning of these relations is straightforward; for example, Works_on has one record per Employee-Project pair such that the Employee Works_on the Project. 1. Write the SQL statements required to create these relations, including appropriate versions of all primary and foreign key integrity...
TM-315 DATABASE SYSTEMS
Please help me to draw an ERD and the Relational Schema and
please mark the Primary and Foreign Key .....
Deliverable:
Word document with grade sheet followed by Part 1 ERD and the
Part 2 relational schema.
Part 1: Draw the ERD for the following situation. 8 pts
Be sure to:
Convert all many-to-many relationships to associative
entities.
Make sure each regular entity has an appropriate identifier.
Make sure attribute names are unique within the ERD
Wally...
Create the database and tables
for the database. Show all SQL statements. Include primary and
foreign keys. Insert data into each table. Show select statements
and display the output of each table. Note:Student’s name must be
inserted into table as part of the data! Perform the SQL below:
Query one table and use WHERE to filter the results. The SELECT
clause should have a column list, not an asterisk (*). State the
purpose of the query; show the query and...
HELP DATABASE QU
Question 1: Think About the relational database table data as given below, write the following queries in Oracle SQL. Company (Cid, Cname, City, Budget, Branch) Department (Deptno, Dname, Building, Cname) Employee (Ename, Deptno, Street, City, Phone, Salary) Works (Ename, Deptno, Hire_date) Location (Cname, Location ) 1. Write Query to Create the Company table, suggest appropriate data type of each attribute, consider that there should be a name for each company. 2. Find employee name/names who live in...
QUESTION 21 Complete the table below by matching each definition with the appropriate SQL clause. -A.B.C.D.E.F.G.H.I.J.K.L.M.N. A mandatory clause that is at the start of all SQL retrieval queries -A.B.C.D.E.F.G.H.I.J.K.L.M.N. A clause used to return only the values in a result table that are unique -A.B.C.D.E.F.G.H.I.J.K.L.M.N. A clause used to filter tuples according to some condition or predicate, like selection in relational algebra -A.B.C.D.E.F.G.H.I.J.K.L.M.N. A clause that is used to list the tables and any joins required in a query...
This is questions of Accounting Information Systems
1) Fo a database. Each row in this spreadsheet represents a: ur Tet Industries tracks customer information using various Microsoft Excel spreadsheets stored in a. Field b. Record c. File d. Database 2) A d tables is a. What is the correct term for the database field in Table 1? latabase field in Table 1 that serves as a unique identifier in Table 2 and is used to link both of the a....