Databases

From 22112
Jump to navigation Jump to search
Previous: Main page Next: MySQL

Material for the lesson

Video: Introduction to databases
Video: How to design a relational database
Powerpoint: Databases
Video: Computer Communication, file transfer, terminal
Powerpoint: Communication
Video: Exercises

Exercises

1) Logging in to a server
In the course we will change between using our personal laptop, Computerome, and the student server: pupil1.healthtech.dtu.dk
In the database exercises we use pupil1. Log into pupil1:

ssh -X s123456@pupil1.healthtech.dtu.dk
Remember to replace s123456 with your s-number or DTU username
Use your DTU password when asked - no chars will be displayed when writing the password
You will then be asked to enter the MFA code you set up with DTU mail.

The -X means you can use X on unix which may only be relevant for you if you run a X-server on your own computer.

Run the ’mysql’ command as described in the powerpoint. Do ’show databases;’ for fun or just ’quit’.

The text editors available on pupil1 are:

geany     X11-based
gedit     X11-based
jedit     X11-based
nano      text-based
vim       text-based

This entire exercise is just proof of concept and will make you ready for next week.

2) Design your own relational database
Design what tables you should use. That includes the names of the fields and the types of the fields. Which fields are primary keys and which are foreign keys. How the tables relate to each other. No programming is involved.

Your database/tables must be able to model this scenario:
Model people. People get married and divorced. People have kids, not necessarily with their spouses. People get sick with zero or more diseases. The diseases start a a given time. You must be able to keep track of their diseases, so it is possible to track heritable diseases. You can obviously be sick from the same disease more than once.

Think about the reality - described in above two lines - that you must model.

Just to be nice, I will not throw polygamy, homosexual marriages, group marriages or 2D marriages into the model. You can also assume that every disease can be identified and is not just a bunch of symptoms.

3) Change the database model
Let us be modern and creative so people can marry in other ways than just single male to single female - follow the times...
Also, people actually die. Put that fact into the model. Explain what constraints that will put on your data?
Here is an example of what I mean by constraints: Joe and Jane are married. Joe dies. Who is Jane married to?
The database must be able to reflect and contain this kind of changes.