Download presentation
Presentation is loading. Please wait.
Published bySydney Sullivan Modified over 9 years ago
1
Seminar #1 – Refreshing databases concepts and SQL CM036: Advanced Databases1 Seminar 1: Revisiting Databases and SQL Purpose To refresh basic concepts of databases. To refresh SQL. Scenario – Human Resources (HR) In the company's human resource records, each employee has a unique identification number, email address, job identification number, salary, and manager. Some employees earn a commission in addition to their salary, which is also tracked. The company also tracks information about jobs within the organization. Each job has an identification number, job title, and a minimum and maximum salary range for the job. Some employees have been with the company for a long time and have held different jobs within the company. When an employee switches jobs, the company records the start date and end date of the former job, the job identification number, and the department. The sample company is regionally diverse, so it tracks the locations of not only its warehouses but also of its departments. Each of the company's employees is assigned to a department. Each department is identified by a unique department code and a short name. Each department is associated with one location. Each location has a full address that includes the street address, postal code, city, state or province, and country code. For each where it has facilities, the company records the country name, currency symbol, currency name and the region where the county resides geographically.
2
Seminar #1 – Refreshing databases concepts and SQL CM036: Advanced Databases2 HR Relational Schema Entity Relationship Diagram (ERD) Creating Schema Download the script file: oracle_script.sql.txt into U:\CM036\W1 from the Blackboard or http://computing.unn.ac.uk/staff/cgma2/cm036/W eek1/ http://computing.unn.ac.uk/staff/cgma2/cm036/W eek1/ Run the script at the SQL* Plus prompt e.g. @U:\CM036\W1\oracle_script.sql.txt
3
Seminar #1 – Refreshing databases concepts and SQL CM036: Advanced Databases3 Sample Table Descriptions
4
Seminar #1 – Refreshing databases concepts and SQL CM036: Advanced Databases4 Sample Table Descriptions …
5
Seminar #1 – Refreshing databases concepts and SQL CM036: Advanced Databases5 Tasks for the Seminar A. Discuss the following questions with the student next to you: 1. What is a database? 2. What are databases used for? 3. What is a relational database? 4. What are the basic elements of the relational data model? B. Write SQL queries using Oracle SQL* Plus to answer the following: 1. Show the structure of the DEPARTMENTS table. Select all data from the table. 2. Create a query to display the last name, job code, hire date, and employee number for each employee, with employee number appearing first. 3. Create a query to display unique job codes from the EMPLOYEES table. 4. Create a query to display the last name and salary of employees earning more than 12,000. 5. Display the employee last name, job ID, and start date of employees hired between February 20, 1998, and May 1, 1998. Order the query in ascending order by start date. 6. Write a query to display the last name, department number, and department name for all employees. 7. Display the employee last name and department name for all employees who have an a (lowercase) in their last names.
6
Seminar #1 – Refreshing databases concepts and SQL CM036: Advanced Databases6 Tasks for the Seminar … 8. Display the employee last name and employee number along with their manager’s last name and manager number. Label the columns Employee, Emp#, Manager, and Mgr#, respectively. 9. Create a query that displays employee last names, department numbers, and all the employees who work in the same department as a given employee. Give each column an appropriate label. 10. Display the names and hire dates for all employees who were hired before their managers, along with their manager’s names and hire dates. Label the columns Employee, Emp Hired, Manager, and Mgr Hired, respectively.
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.