Question

I need to use SQL in microsoft access to deal with those problems. Have no ideal...

I need to use SQL in microsoft access to deal with those problems. Have no ideal on how to edit the code. Here is the requirement.

Database Design and Relationships
1. Create Primary Key(s) as appropriate for all tables. In TIMESHEETS, employees can only log time to a given WORKCODE once per day (e.g., if someone works on R&D for 2 hours in the morning and 2 hours in the afternoon, it's entered on the timesheet as 4 hours for R&D).
2. Create relationships between tables and enforce referential integrity.

Queries
Create the following queries using the names shown (i.e., including the leading number):
1-NUMBER OF EMPLOYEES BY DEPARTMENT: answers the question, "How many employees work for each department?" Include fields: NUMBEROFEMPLOYEES, DEPARTMENT.
2-TOTALPAY BY DEPARTMENT: answers the question, "How much total salaries are paid to each department?" Include fields: DEPARTMENT and a calculated field called TOTALPAY defined as HOURS*PAYBYHOUR.
3-TOTALPAY BY EMPLOYEE: answers the question, "What are the salaries paid to each employee?" Include fields: EMPLOYEEID, DEPARTMENT, WORKDATE, WORKCODE, WORKCODES. WORKNAME, HOURS, PAYBYHOUR, and a calculated field called TOTALPAY defined as HOURS*PAYBYHOUR.
4-TOTALPAY BY JOBTITLE: answers the question, "How much total salaries are paid to each job title (e.g., Business Analyst, Business Consultant)?" Include fields: JOBTITLE and a calculated field called TOTALPAY defined as HOURS*PAYBYHOUR.
5-TOTALPAY BY PAYBAND: answers the question, "How much total salaries are paid for each pay band?" Include fields: PAYBAND and a calculated field called TOTALPAY defined as HOURS*PAYBYHOUR.
6-TOTALSALARIES: answers the question, "What is the total amount salaries paid"?

Just need the code like :

SELECT PRODID, PRODNAME, PRICE

FROM PRODUCTS

WHERE PRICE > 200;

EMPLOYEES

employee id last name first name job title payband zone department street city state zip code

PAYBANDS

PAYBAND ZONE PAYBYHOUR JOBTITLE

TIMESHEETS

EMPLOYEEID WORKDATE WORKCODE HOUR

WORKCODES

WORKCODE WORKNAME DESCRIPTION
0 0
Add a comment Improve this question Transcribed image text
Answer #1

1. Creating appropriate primary keys: This has to be decided looking at the data but we can make certain calls looking at the column names.

How to create primary key is access file:

Open a Microsoft access files with respective tables on it already or else can be added by using the object browser.

Right click on the table name and select design view and wherein primary key can be selected using primary key option.

Table1: Employees

EmployeeId seems to be ideal primary key. But if that is indeed an identity key then a combination of first name, last name, street, zip code seems to be next ideal primary key. Let us assume that Employee Id is not identity hence a primary key.

Table2: Paybands

Payband is a primary key as there cannot be more than one payband

Table3: TimeSheets

There is an explicit statement mentioned in the requirement that an employee can work in one department only in a day. Hence the primary key goes on a combination of EmployeeId, WorkDate, Workcode

Table4: Workcodes

Workcode column seems to be an ideal primary key. If there can be multiple worknames in a single workcode, then WorkName seems to be next ideal choice.

2. At the same place we can find option to create foreign keys known to establish referential integrity.

Foreign keys are mainly on key columns. EmployeeId from Employee table is referenced everywhere else as a foreing key.

Workcode from workcodes table is referenced as foreing key in Timesheets table

Payband from Paybands table is referenced as foreing key in Employee table

Queries:

2.1:NUMBER OF EMPLOYEES BY DEPARTMENT: answers the question, "How many employees work for each department?" Include fields: NUMBEROFEMPLOYEES, DEPARTMENT.

SELECT Count(EmployeeId) as NUMBEROFEMPLOYEES, DEPARTMENT

FROM Employee

Group By DEPARTMENT;

2.2 TOTALPAY BY DEPARTMENT: answers the question, "How much total salaries are paid to each department?" Include fields: DEPARTMENT and a calculated field called TOTALPAY defined as HOURS*PAYBYHOUR.

Select Department, sum(Hours*PaybyHour) as TOTALPAY

FROM Employee e inner join PAYBANDS p on e.Payband = p.Payband

inner join TIMESHEETS t on t.EmployeeId = e.EmployeeId

group by Department

2.3-TOTALPAY BY EMPLOYEE: answers the question, "What are the salaries paid to each employee?" Include fields: EMPLOYEEID, DEPARTMENT, WORKDATE, WORKCODE, WORKCODES. WORKNAME, HOURS, PAYBYHOUR, and a calculated field called TOTALPAY defined as HOURS*PAYBYHOUR.

Select e.EMPLOYEEID,sum(Hours*PaybyHour) as TOTALPAY

FROM Employee e inner join PAYBANDS p on e.Payband = p.Payband

inner join TIMESHEETS t on t.EmployeeId = e.EmployeeId

inner join Workcodes w on w.Workcode = t.Workcode

group by e.EMPLOYEEID

2.4-TOTALPAY BY JOBTITLE: answers the question, "How much total salaries are paid to each job title (e.g., Business Analyst, Business Consultant)?" Include fields: JOBTITLE and a calculated field called TOTALPAY defined as HOURS*PAYBYHOUR.

Select p.JOBTITLE,sum(Hours*PaybyHour) as TOTALPAY

FROM Employee e inner join PAYBANDS p on e.Payband = p.Payband

inner join TIMESHEETS t on t.EmployeeId = e.EmployeeId

inner join Workcodes w on w.Workcode = t.Workcode

group by p.JOBTITLE

2.5-TOTALPAY BY PAYBAND: answers the question, "How much total salaries are paid for each pay band?" Include fields: PAYBAND and a calculated field called TOTALPAY defined as HOURS*PAYBYHOUR.

Select p.Payband,sum(Hours*PaybyHour) as TOTALPAY

FROM Employee e inner join PAYBANDS p on e.Payband = p.Payband

inner join TIMESHEETS t on t.EmployeeId = e.EmployeeId

inner join Workcodes w on w.Workcode = t.Workcode

group by p.Payband

2.6-TOTALSALARIES: answers the question, "What is the total amount salaries paid"?

Select sum(Hours*PaybyHour) as TOTALPAY

FROM Employee e inner join PAYBANDS p on e.Payband = p.Payband

inner join TIMESHEETS t on t.EmployeeId = e.EmployeeId

inner join Workcodes w on w.Workcode = t.Workcode

Hope this helped!

Add a comment
Know the answer?
Add Answer to:
I need to use SQL in microsoft access to deal with those problems. Have no ideal...
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
  • SQL queries and procedures TABLE: Employees Business Rules: EmployeeID is defined as the primary key. Address...

    SQL queries and procedures TABLE: Employees Business Rules: EmployeeID is defined as the primary key. Address has been denormalized to include City and State for performance reasons. DeptNbr is a foreign key that references DeptNbr in the Department table Manager is a foreign key that references EmployeeID in the Employees table Data Structure: (EmployeeId, LastName, FirstName, Street, City, State, Zip, DateOfHire, DateOfBirth, JobTitle, Salary, DeptNbr(fk), Manager(fk)) TABLE: Department Business Rules: DeptNbr is defined as the primary key. Data Structure: (DeptNbr,...

  • I have already turned in my HW, I need some understanding of the below SQL queries....

    I have already turned in my HW, I need some understanding of the below SQL queries. 1. Find the number of employees in each department. 2. List the names of departments that have more than 5 employees working there. 3. Retrieve the lowest and highest salary in each department. Output the department name in alphabetical order. Consider the following relational schema. An employee can work in more than on department; also, the percentTime field of the Works relations shows the...

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

  • If the employee is a supervisor calculate her paycheck as her yearly salary / 52 (weekly...

    If the employee is a supervisor calculate her paycheck as her yearly salary / 52 (weekly pay) If the employee is not a supervisor and she worked 40 hours or less calculate her paycheck as her hourly wage * hours worked (regular pay) If the employee is not a supervisor and worked more than 40 hours calculate her paycheck as her (hourly wage * 40 ) + (1 ½ times here hourly wage * her hours worked over 40) (overtime...

  • Part I. Create a library check-out database using Microsoft SQL Server that stores data about books,...

    Part I. Create a library check-out database using Microsoft SQL Server that stores data about books, patrons, and the check-out process. Books (BookID, BookName, Author, YearPublished) Patrons (PatronsID, PatronsName, PatronsAddress, PatronsBirthday) CheckInOut (TransactionID, PatronID, BookID, CheckOutDate, NumDay, ReturnDate, Late, Fees, Paid) - the NumDay field contains the number of days patrons can keep the book, if the return date is over the number of day, then the Late field will have a Y value and a fee of $1.00 per...

  • I need help with the following SQL query for a company database (script given below). The...

    I need help with the following SQL query for a company database (script given below). The name of the Department. The number of employees working in that department. The number of different projects controlled by this department. The name of the project controlled by this department that has the maximum number of employees of the company working on it. The number of the above project. The cumulative sum of the number of employees of the company working on the projects...

  • The Northwind database created by Microsoft contains the sales data for a fictitious company called Northwind...

    The Northwind database created by Microsoft contains the sales data for a fictitious company called Northwind Traders, which imports and exports specialty foods from around the world. Here is the schema of the database: Products (ProductID, ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued); Suppliers (SupplierID, CompanyName, ContactName , ContactTitle, Address, City, Region, PostalCode, Country, Phone, Fax, HomePage); Categories (CategoryID, CategoryName, Description, Picture); Orders (OrderID, CustomerID, EmployeeID, OrderDate, RequiredDate, ShippedDate, ShipVia,  Freight, ShipName,ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry); Order_details (ID, OrderID,...

  • Please answer this questions as required I couldn't delete the old pic so the new one is butter and...

    Please answer this questions as required I couldn't delete the old pic so the new one is butter and for the same question. RealGree uses the paper form as below to record the weekly (just one week in this 5. A lawn and tree care company ion) informati application to keep track of the information of the part-time employees. Please (a) develop the E-R diagram (8 points). ion about is part-time employees (one form for one employee). The company asks...

  • Return the acnum of academic(s) who wrote the largest number of papers. You must NOT use MAX. An SQL query that lists all academics in decreasing order of their total number of papers is incorrect....

    Return the acnum of academic(s) who wrote the largest number of papers. You must NOT use MAX. An SQL query that lists all academics in decreasing order of their total number of papers is incorrect. Question 1. SQL (10 points) In addition to the lecture notes, you should also study by yourself the SQL Plus tutorial on Canvas (the Oracle section) and other resources for syntax and useful functions The relational schema for the Academics database is as follows descrip,...

  • I am using Oracle SQL and am new to it. I have seven tables, one of...

    I am using Oracle SQL and am new to it. I have seven tables, one of them is a subtable of two of the others. I need to do the following queries: 1. List all Patients and what Bed they are assigned to 2. List all patients who had Treatments and what Treatment they received 3. List all patients who had tests and what Test they had 4. List the employees (doctors, nurses, etc.) who assisted each patient. 5. List...

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