Question

In: Computer Science

Q2: Get SSN and the last name of married female employees who work on three or...

Q2: Get SSN and the last name of married female employees who work on three or more projects Write Q2 in Relational Algebra:

Solutions

Expert Solution

Solution:

Schema of required tables

Employee ( SSN,LNAME,FNAME,SEX)

Dependent(ESSN,Relationship)

Workson(ESSN,PNO)

Write relation algebra query part by part and then combine all to get the final query.

First find the female employees from employee table

Female_Employees = ∏ SSN ( ( σ SEX = ‘F’ (Employee)))

After finding the female employees find the employee ids whose relationship is spouse . This gives the result of married employees.

So Query is

Married_Employees = ∏ESSN ( ( σRelationship = ‘Spouse’ (Dependent) ))

Now combine the first two queries to get the female married employees i.e

Married_Female_Employees =  ∏SSN (Female_Employees ⋈SSN=ESSN Married_Employees )

After that find the employees whose count of project numbers is greater than or equal to 3 from workson table.

So the query is

Employees_more_than_3_projects = ( σCount(pno) >= 3 (ESSN F COUNT(pno) WORKS_ON))

So the above query gives the results of more than 3 projects employees.

And then Join Married_Female_Employees and Employees_more_than_3_projects on SSN Column

output1 = ∏SSN(Married_Female_Employees ⋈ SSN=ESSN Employees_more_than_3_projects )

Now do output1 natural join with employee table on common column ssn to get the last name of employee.

i.e

Final_Output= ∏SSN,LNAME (Employee * output1 )

So the final query is

Final_Query = ∏SSN,LNAME (Employee * (∏SSN((SSN ((∏ SSN ( ( σ SEX = ‘F’ (Employee))))⋈SSN=ESSN (∏ESSN ( ( σRelationship = ‘Spouse’ (Dependent) ))))) SSN=ESSN (( σCount(pno) >= 3 (ESSN F COUNT(pno) WORKS_ON))) )))

Note: It's very difficult to understand the query if we write directly so derive each part and then combine all parts is better.

Note: if you have any queries please post a comment thanks a lot..always available to help you...


Related Solutions

Create a table ‘StudentInfo’ with following fields: ID First Name Last Name SSN Date of Birth...
Create a table ‘StudentInfo’ with following fields: ID First Name Last Name SSN Date of Birth Create a table ‘ClassInfo’ table: ID Class Name Class Description Create a table ‘RegisteredClasses’ table: StudentID ClassID The RegisteredClasses table should have a foreign key relationship to StudentInfo and ClassInfo tables for the respective IDs. Also the IDs in StudentInfo and ClassInfo need to be primary keys. When you submit the file your email should also contain the following SQL Queries: Query to show...
Retrieve the SSN and salary of the employee who work for the headquarter department. 2. List...
Retrieve the SSN and salary of the employee who work for the headquarter department. 2. List all the departments name , the manager’s name of each department and the location of each department. List the last name of each employee whose salary is more than 30,000 and the last name of his/her supervisor
USE ORACLE - SQL List the name and salary of employees who work for division 3....
USE ORACLE - SQL List the name and salary of employees who work for division 3. List the name of project whose budget is between 5000-7000 List the total number of employee whose initial of name is 's'. (hint, using LIKE operator and wildcard character) List the total number of employee whose initial of name is NOT 's' for each division, including division ID List the total project budget for each division, including division ID. List the ID of the...
a soap manufacturing company has three employees who work in a warehouse All of the warehouse...
a soap manufacturing company has three employees who work in a warehouse All of the warehouse workers are authorized to order inventory when it falls below order level.The workers complete a purchase order and mail it to supplier of their choice .The inventory is delivered directly to the warehouse .The workers send a memo to accounts payable reporting receipt of inventory accounts payable compares warehouse memo to suppliers invoice .Accounts payable prepares a memo which treasurer signs .discuss internal control...
Wendy O"neil (SSN 412-34-5670), who is single, work full time as the director at a local...
Wendy O"neil (SSN 412-34-5670), who is single, work full time as the director at a local charity. She resides at 1501 Front St Highland, AZ 85711 for the year. she had the following on her w2 wages 46200 federal withholding 6930 social security wages 46200 social security withholding 2864 medicare withholding 670 state withholding 2310 other information 1099-int 300 1099 div ordinary 400 qualified 400 itemized state income 2310 state income tax paid with the 2016 return 100 real estate...
Donna is a 35 year old female who is married and has a 5 year old...
Donna is a 35 year old female who is married and has a 5 year old daughter. Donna recently found out she was pregnant, but last week at 12 weeks she started to spot and went to see the doctor. At the doctors, Donna found out she was having a miscarriage and the doctors decided to look at her blood type and seemed very alarmed and asked her who her doctor was for her first child. Her blood type was...
Last year, 50% of MNM, Inc., employees were female. It is suspected that there has been...
Last year, 50% of MNM, Inc., employees were female. It is suspected that there has been a reduction in the percentage of females in the company. This year, in a random sample, 400 employees were male, 380 were female. a. State the null and the alternative hypotheses. b. At the .05 level using the critical value approach, determine if there has been a significant reduction in the proportion of females. c. Show that the p-value approach results in the same...
Alex, who is married and the father of four, is age 45 and expect to work...
Alex, who is married and the father of four, is age 45 and expect to work to age 65. He earns $70,000 per year and expects annual salary increases of 5%. Alex expects inflation to be 4% over his working life. His personal consumption is earl to 10% of after tax earnings, and his combined federal and state marginal tax bracket is 20%. Human Life Approach (a) calculate the family’s share of earnings (b) Calculate work life expectancy (c) calculate...
Mildred is a 45-y.o. married female with three children. She presents to you with complaints of...
Mildred is a 45-y.o. married female with three children. She presents to you with complaints of fatigue and difficulties sleeping. She states she wants to get a good night’s sleep and is requesting a prescription to help her sleep. Mildred tells you she is awake off and on during the night, frequently thinking about her husband’s recent layoff from construction work and the effect this is having on the family. She lies down often during the day and has been...
Karen and Paul are a married couple who work as accountants. They set up their own...
Karen and Paul are a married couple who work as accountants. They set up their own self-managed superannuation fund. They have chosen to be individual trustees. The trust deed includes the following clauses: ‘1. This fund is to cease operating on 1 January 2030. 2. Benefits can only be taken in the form of a lump sum.’ Advise Karen and Paul as to any issues that might arise regarding the particular clauses referred to.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT