Scenario: you have been tasked with summarizing and extracting information from the NYC payroll department. This data is a blend of simulated data along with a sample of real data from NYC Open Data" and the following two questions in a "Discussion" section: 1)What type of relationship do you find between tblPayroll and tblEmployeeNames? A) One-to-many (Or Many-to-One) B) One-to-One C) Cannot be determined D) Left Outer Join
Sorry, this is so messed up that I do not think I could answer correctly. I can fix it and have it make sense. But it is like answering gibberish. It is unfortunate, to use this to try to teach someone.
If you cannot add additional fields, and assume that all tables have a PK then you are stuck with a 1 to 1, but makes no logical sense.
If you chose EmployeeID as the PK for Payroll then it is a 1 to 1 and since you cannot add a PayrollID you are stuck. You can only add one record for each employee.
If you leave EmployeeID as a foreign key then it is a 1 to Many. You can add many more payroll entries. But in this example there is not a PayrollID.
1. Even if it made sense. You cannot establish a relationship (enforce referential integrity) because there are orphan records in payroll. There are payroll items without Employees. In order to establish a relation you need to first get rid of orphan records. Again you can join in a query on anything that is the same datatype, a relation is when referential integrity is established.
2. Table are not normal making the question nonsensical. They combine Employee info and payroll period info.
3 Logically it should be a 1 to Many. An Employee should have many payroll entries. That means you need a PayrollID and a PayrollDate to uniquely identify an entry. (Also want to index
Show the prof my design in #28 and tell them that would make sense.
Create a left outer Join from Employees to Payroll if you want to summarize information for all employees and pay information for those that have it. You can create a left outer join from Payroll to Employees to summarize all payroll information and information about employees that have payroll information.
There are orphans both ways.
You have employees without payroll information (that is OK I guess, depending on what the data is supposed to show)
You have paryroll information without employees (normally this is bad)