This homework assumes you have installed the software MySQL to your computer. If not please do that first!
- Practice the concepts
- MySQL exercises
Let's do some interactive exercises first. In the following online course, do sections 3 (Aggregate Functions) and sections 4 (Multiple Tables).
Also make time to do lesson 6-12 from the following:
You will need to do some research to solve these exercises. All the concepts necessary to solve these exercises are NOT covered in the reading material. This is on purpose.
This week we'll practice some more with writing SQL queries using JavaScript. For each exercise make a separate .js
file; make sure to give it an appropriate name!
Exercise 1: Keys
- Create a table, called
authors
. Give it the following fields:(author_no(Primary Key), author_name, university, date_of_birth, h_index, gender)
- Write a query that adds a column called
mentor
toauthors
table that references the columnauthor_no
. For integrity add aforeign key
on this column.
Exercise 2: Relationships
- Create another table, called
research_Papers
with the following fields:(paper_id, paper_title, conference, publish_date, ...)
- What is the relationship between Authors and Research papers ? Make necessary changes to
authors
andresearch_Papers
tables and add more tables if necessary. - Read exercises 3 and 4 and then add information (insert rows) of 15 authors and 30 research papers such that all queries in the exercises 3 and 4 will return some answers
Exercise 3: Joins
- Write a query that prints names of all
authors
and their correspondingmentors
. - Write a query that prints all columns of
authors
and their publishedpaper_title
. If there is an author without anyresearch_Papers
, print the information of thatauthor
too.
Exercise 4: Aggregate Functions
Write some queries to retrieve the following rows:
- All research papers and the number of authors that wrote that paper.
- Sum of the research papers published by all female authors.
- Average of the h-index of all authors per university.
- Sum of the research papers of the authors per university.
- Minimum and maximum of the h-index of all authors per university.
After you've finished your todo list it's time to show us what you got! The homework that needs to be submitted is the following:
- MySQL exercises
Upload both to your forked Databases repository in GitHub. Make a pull request to HackYourFuture's forked repository.
Forgotten how to upload your homework? Go through the guide to learn how to do this again.
Deadline Thursday 23.59 CET