Question

BONUS QUESTION: Suppose you have two tables, EMPLOYEES with primary key employee_ID, and DEPARTMENTS with primary...

BONUS QUESTION:

Suppose you have two tables, EMPLOYEES with primary key employee_ID, and DEPARTMENTS with primary key department_ID. Assume each department may have many employees, but each employee is only assigned one department.

What would be the correct SQL syntax for retrieving data from both tables?

(HINT: You must find out what is the foreign key)

A. SELECT employee_ID, employee_name, department_ID, department_location

FROM Employees JOIN Departments ON Employees.employee_ID = Departments.employee_ID;

B. SELECT employee_ID, employee_name, department_ID, department_location

FROM Employees JOIN Departments ON Departments.employee_ID = Employees.employee_ID;

C. SELECT employee_ID, employee_name, department_ID, department_location

FROM Employees JOIN Departments ON Employees.department_ID = Departments.department_ID;

D. SELECT employee_ID, employee_name, department_ID, department_location

FROM Employees JOIN Departments ON Employees.employee_ID = Departments.department_ID;

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

Answer:-

C.

SELECT employee_ID, employee_name, department_ID, department_location

FROM Employees JOIN Departments ON Employees.department_ID = Departments.department_ID;

Add a comment
Know the answer?
Add Answer to:
BONUS QUESTION: Suppose you have two tables, EMPLOYEES with primary key employee_ID, and DEPARTMENTS with primary...
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
  • MYSQL Applied Database I just want to make sure that the syntax looks okay for my...

    MYSQL Applied Database I just want to make sure that the syntax looks okay for my database SQL statements, any help would be much appreciated: 1.A query that asks for customer star review for Tony Stark on Opportunity Detail. SELECT CONCAT (employee_first_name,' ',employee_last_name) AS                            employee_name, review_star_count, FROM customer_reviews, JOIN e employees ON employee_id =employee_id, WHERE employee_id=4 AND opportunity_id=1; 2.A query that shows how many orders Additional Dot Twain License, in an order totaling over $900. SELECT product_name, COUNT(o.OrderID) AS...

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

  • The database(or the tables) are follow: CREATE TABLE employees ( id SERIAL NOT NULL PRIMARY KEY,...

    The database(or the tables) are follow: CREATE TABLE employees ( id SERIAL NOT NULL PRIMARY KEY, name TEXT NOT NULL, salary REAL NOT NULL DEFAULT 25000.0 ); CREATE TABLE employee_audit_log ( employee_id INTEGER NOT NULL, occurred_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ); INSERT INTO employees(name, salary) VALUES ('Arnold Schwarznegger', 35000), ('Yuri Gargarin', 27000), ('Anakin Skywalker', 450000), ('Said Faroghi', 15000), ('Zino Holwerda', 8500); 1. Create a trigger for the employees table so that a new row is inserted in employee audit_log...

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

  • Write SQL Queries Given the following tables (7pts) Retrieve the names of employees and their project...

    Write SQL Queries Given the following tables (7pts) Retrieve the names of employees and their project name. If the employee never worked on a project, show the names only the name, not the project name. (7pts) Retrieve the names of employees who have worked on the same project at a different location. (7pts) Retrieve the names of employees who have worked on more than two different projects. (7pts) Retrieve the names of employees who manage more than two employees. CREATE...

  • Questions: Assume you are creating a database for IS paint store. Suppose you have an ER diagram ...

    Questions: Assume you are creating a database for IS paint store. Suppose you have an ER diagram like the following: Please answer the following questions. Explain your answer. 1. Convert the ER diagrams to relational tables. 2. Specify primary keys and foreign keys in each table. For foreign keys, specify which primary key it references to. 3. Please create the tables in SQL for the relational tables in our ER diagrams. You also need to define primary keys and foreign...

  • The employee is table, the best candidate for primary key is Select one: a. Department ID...

    The employee is table, the best candidate for primary key is Select one: a. Department ID b. Employee hiredate c. Employee ID d. Employee salary Question 2 A primary key can be composed of more than one attribute. Select one: True False Question 3 A foreign key allows you to join two tables. Select one: True False Question 4 Given two tables, department (dept_id, dept_location, dept_name) and EMPLOYEE(emp_id, emp_name, emp_dept_id, emp_name, emp_salary), which attribute (column) is the foreign key? Select...

  • Suppose you have two tables: Table Product: PROD_ID PROD_NAME PROD_PRICE PROD_PROD_DATE PROD_VENDOR 1101 Table 100 1-Jan-18...

    Suppose you have two tables: Table Product: PROD_ID PROD_NAME PROD_PRICE PROD_PROD_DATE PROD_VENDOR 1101 Table 100 1-Jan-18 2 1102 Chair 80 3-Mar-18 3 1103 Armchair 90 6-May-18 2 1104 Nightstand 110 4-Apr-18 1 1105 Bed 200 3-Mar-18 3 1106 Dresser 150 5-May-18 3 1107 Daybed 190 10-Feb-18 2 Table Vendor: VEND_ID VEND_NAME VEND_ST 1 Green Way Inc GA 2 Forrest LLC NC 3 AmeriMart NC Post a question or provide an answer on the discussion board “Help with labs REQUIRED weekly...

  • Code in sql/oracle 8. What departments have no employees and what employees have no departments. Show the result of the question through ONLY one query/SELECT statement. Do not write two separate sele...

    Code in sql/oracle 8. What departments have no employees and what employees have no departments. Show the result of the question through ONLY one query/SELECT statement. Do not write two separate select statements.

  • 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