Uploaded by huijin.teh

REVIEW C4

advertisement
Use the following business rules to create a Crow's Foot ERD. Write all appropriate
connectivity and cardinalities in the ERD.
–
A department employs many employees, but each employee is employed by only one
department.
–
Some employees, known as "rovers," are not assigned to any department.
–
A division operates many departments, but each department is operated by only one
division.
–
An employee may be assigned many projects, and a project may have many employees
assigned to it.
–
A project must have at least one employee assigned to it.
–
One of the employees manages each department, and each department is managed by only
one employee.
–
One of the employees runs each division, and each division is run by only one employee.
a. Identify and discuss each of the indicated dependencies.
b. Create a database whose tables are at least in 2NE, showing the dependency diagrams for
each table.
c. Create a database whose tables are at least in 3NE, showing the dependency diagrams for
each table
a. Write the relational schema, draw its dependency diagram, and identify all dependencies,
including all partial and transitive dependencies. You can assume that the table does not contain
repeating groups and that an invoice number references more than one product. (Hint: This
table uses a composite primary key.)
b. Remove all partial dependencies, write the relational schema, and draw the new dependency
diagrams. Identify the normal forms for each table structure you created.
4.
a.
SELECT airlinename, routes.airline_id, count(*) AS total_routes FROM routes, airline
WHERE airline.airlineid = routes.airline_id GROUP BY routes.airline_id ORDER BY
total_routes desc;
b.
SELECT airlinename, routes.airline_id, count(*) AS total_routes FROM routes, airline
WHERE
airline.airlineid = routes.airline_id AND airlinename LIKE '%china%' AND airlinename LIKE
'%airlines%' GROUP BY routes.airline_id having
count(*) > 1000 ORDER BY total_routes desc;
c.
SELECT airportname, routes.source_airport_id, count(*) AS total_business_for_taking_off
FROM routes, airport WHERE airport.airportid = routes.source_airport_id
GROUP BY routes.source_airport_id ORDER BY total_business_for_taking_off desc;
d.
SELECT airportname, routes.source_airport_id FROM routes, airline, airport WHERE
airport.airportid = routes.source_airport_id AND
airline.airlineid = routes.airline_id AND airline.country = 'canada' GROUP BY
routes.source_airport_id;
e.
SELECT airlinename FROM airline WHERE airlineid IN (SELECT routes.airline_id FROM
routes WHERE airline_id >
(SELECT AVG(airline_id) FROM routes));
5.
INSERT
INTO
airline
("19846","Airasia","null","AK","AXM","null","Malaysia","Y");
VALUES
Download