Skip to content

Week3 MAKEME

Andrej edited this page Nov 26, 2019 · 10 revisions

Homework week 3

This homework is divided into several exercises. Please submit each exercise in a separate folder.

Exercise 1 : Normal forms

Hack Your Future is building a new website and we need your help. This is the data we want to show for each course/class.

class data

The idea was to create two tables: class(id, description, numberofstudents, startdate, teacherid, teachername, teacheremail) and students(id, name, grade).

Can you help us to normalize the database? Write a single javascript file with commands to create the tables for the database and insert the data from the example above.

Exercise 2 : Transactions

In this exercise you will use the company database.

It turns out that many department are adopting a flat structure. In this flat structure, there is one manager for the department and everyone reports to him. There are no middle-managers. You need to write a javascript function that access as parameters a department number and employee number function flatify(dept_no, emp_no). The function then updates the database and makes this employee a manager for the department and also sets all employees in that department to report to him. Because the function uses two queries make sure to use transactions. In case of an error rollback the transaction.

Exercise 3 : SQL injection

Clone this wiki locally