Question

Q.5] Answer the following questions based on the company database (based on the homework assignment 2)
y database (based on the homework assignment 2) 3 IPage 1. For each department whose average employee salary is more than $30


Homework Assignment 2 In this homework, you will practice how to create company database schema (DBMS specific database or ph
Q.5] Answer the following questions based on the company database (based on the homework assignment 2)
y database (based on the homework assignment 2) 3 IPage 1. For each department whose average employee salary is more than $30,000, write a SQL statement to retrieve the department name and the number of employees working for that department 2. Write a SQL statement to retrieve first name, last name, and address of each employee who lives in Houston, TX. 3. Write a SQL statement to retrieve the names of employees who have no dependents (use EXISTS clause) 4. Write a SQL statement to create a view Deptinfo which includes DeptName, NoOfEmployees, TotalSalary. Note: use aggregate functions, group by
Homework Assignment 2 In this homework, you will practice how to create company database schema (DBMS specific database or physical database) and its table schemas. You also practice how to populate database tables. You then study how to use ER diagramming tool and forward engineer tool available in the MySQL Workbench. Study SQL scripts explained in chapters 3,4, and 5. Step 1: create database named company by using MySQLWorkbench SQL editor or MySQL command shell. Step 2: download SQL scripts and data to be populated (archived in companyDB.zip) from the course home page and save them in a directory (e.g.. /usr/home/gjung/MyDBs /companyTest or C:MyDBslcompanyTest). Change directory to MyDBs/company, and type source source.sq: Then database company tables are created in MySQL. The company database tables are populated by loading data from CSV (comma separated value) files by the SQL scripts. See the content of source.sql to understand physical database generation (including data population). To enter mysql CLI (we assume your PATH environment variable is properly set to the folder where mysql command is stored): In Windows: Smysql-u username p //then enter password In UNIX: Smysql -local-infile -u username p//then enter password Step 3: Open companyTest.mwb file with MySQL Workbench, and see the tables and their relationships in the MySQL Workbench. Study how to generate SOL script by forward engineer tool available in the MySQL Workbench. Step 4: Preview and practice SQL query examples which will be studied in chapter 4 and chapter 5
0 0
Add a comment Improve this question Transcribed image text
Answer #1

--1

Select d.dname,count(e.ssn) From department d inner join employee e on d.dnumber=e.dno group by d.dname having Avg(e.salary)>30000;

We have joined department and emploee table to get dname and used group by department to get count and avg of salary. Having clause helps to filter data.

--2

select fname,lname , Address from employee where address like '%Houston, Tx%';

with help of wild character % and like condition we are checking for string in address column data.

--3

select fname from employee where exist (select dno from employee e1 on employee.dno=e.dno and e1.dno is null);

Above query we have used exist operations and null condition to get employees names whose dno is null;

--4

Select d.dname,count(e.ssn) As NumOfEmployee,Sum(e.salary) As TotalSalary From department d left join employee e on d.dnumber=e.dno group by d.dname;

Add a comment
Know the answer?
Add Answer to:
Q.5] Answer the following questions based on the company database (based on the homework assignment 2) y dat...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a database called COMPANY using those generated SQL scripts in MySQL database. Show the screenshot...

    Create a database called COMPANY using those generated SQL scripts in MySQL database. Show the screenshot of your database and tables in MySQL. To manage your database, you can use the phpmyadmin tool or MySQL Workbench.

  • For this set of Review Questions, we will create and use a database for the Wedgewood...

    For this set of Review Questions, we will create and use a database for the Wedgewood Pacific Corporation (WPC) that is similar to the Microsoft Access database we created and used in Chapters 1 and 2. Founded in 1957 in Seattle, Washington, WPC has grown into an internationally recognized organization. The company is located in two buildings. One building houses the Administration, Accounting, Finance, and Human Resources departments, and the second houses the Production, Marketing, and Information Systems departments. The...

  • Q.1] Write SQL statements based on the tennis database schema (practice homework 5) Get all the different tow...

    Q.1] Write SQL statements based on the tennis database schema (practice homework 5) Get all the different town names from the PLAYERS table. 2. For each town, find the number of players. 3. For each team, get the team number, the number of matches that has been played 'for that team, and the total number of sets won. 4. For each team that is captained by a player resident in "Eltham", get the team number and the number of matches...

  • Through the remaining assignments due in this course, you will be creating a simple database for...

    Through the remaining assignments due in this course, you will be creating a simple database for tracking information about volunteers working and raising money for a community organization. This assignment requires that you create the initial table, called PERSON, to hold basic information about volunteers. You will be redefining the design and building the database in the upcoming unit assignments. 1.Use the mysqldump.exe command line tool to backup the data in your volunteer database. To access the mysqldump.exe tool, start...

  • Can you please upload the video to step by step with eclipse and mysql workbench.please.............

    Can you please upload the video to step by step with eclipse and mysql workbench.please................................ Part 1 Design the database using the ER approach. Then using Java and SQL, implement the following functionality: 1. Implement a button called “Initialize Database” . When a user clicks it, all necessary tables will be created (or recreated) automatically, with each table be populated with at least 10 tuples so that each query below will return some results. All students should use the database...

  • Can you please upload the video to step by step with eclipse and mysql workbench.please................................ Part...

    Can you please upload the video to step by step with eclipse and mysql workbench.please................................ Part 1 Design the database using the ER approach. Then using Java and SQL, implement the following functionality: 1. Implement a button called “Initialize Database” . When a user clicks it, all necessary tables will be created (or recreated) automatically, with each table be populated with at least 10 tuples so that each query below will return some results. All students should use the database...

  • Use MySQL Workbench for these questions. Do NOT use Lucidchart. MySQL Workbench has more capability than...

    Use MySQL Workbench for these questions. Do NOT use Lucidchart. MySQL Workbench has more capability than Lucidchart, as it allows creation of DDL SQL from the model. Turn in 1 Workbench file , 1 document with the forward-engineered sql statements, and a Word document with your inserted data. This problem mimics the one from the previous assignment. Model it in Workbench, then forward-engineer the database script and import into your database. If the import fails, fix it in the model,...

  • Overview: Database management plays an integral role in nearly every area of business. Databases house customer, accoun...

    Overview: Database management plays an integral role in nearly every area of business. Databases house customer, accounting, and employee data, and these different data sets must all be efficiently managed in order to make the data accessible. Companies rely on database engineers to ensure that their records are accurate, updated, and tracked in real time. This course covers structured query language (SQL) and how it can be used to manage database schemas, manipulate data, and analyze data. For your final...

  • database and sql problme THE QUESTIONS 3, 4,5 and 6 REFER TO THE RELATIONAL TABLES LISTED...

    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...

  • IN THE PREVIOUS CHAPTER WE MADE A DATABASE USING OUR LAST NAME AS ITS NAME. QUESTION...

    IN THE PREVIOUS CHAPTER WE MADE A DATABASE USING OUR LAST NAME AS ITS NAME. QUESTION 1 STATES THIS. PLEASE TYPE WHAT NEEDS TO BE TYPED FOR ALL STEPS. THIS USES CODIO a. 1. Connect to the database you created and named in Module One (for example, Jetson). Type after the prompt mysql> a. use (table you named); i. Example: mysql> use Jetson; 2. Create the Employee table using the SQL statement shown here. Press Return after each line. CREATE...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT