Thursday, December 09, 2004

Basic Database Design

At our meeting with Dr. Iba on 12-6-04, he introduced us to basic database design.
We learned that the purpose of a database is to model data, and thus the first step is to determine what exactly we are modeling, and then to break that up into pieces: entity sets (shown by boxes) and relationships (shown by diamonds) between them. Each may have attributes (shown by boxes with rounded corners) which usually include a primary key (underlined) that identifies a tuple uniquely.
We arranged the sets and relationships, thinking about what needed to relate to what and how:

Entity Relationship Diagram


At first we were thinking that the date would be part of the attributes of Readings and Move Mouse, but decided to make Date a separate entity set. Comments likewise was going to be an attribute of Move Mouse, Date of Death (DOD), and Make Reading, but since this would require storing large amounts of data in relationship tables, we decided to make Comments a separate entity also.
We considered how to represent a mouse death. Perhaps using a Move Mouse where the cage it is moved to is called "dead." The date and comments associated with this move would have to be specially identified such that they would display not just as a cage transfer but as Date of Death (DOD) and Comments (type: death).
We realized that there might be a problem if two people enter two readings or moves at the exact same time with the same data. We tabled the problem until a later date.

The next task was to define relations (tables) based on the attributes. We decided to use MySQL, and were given accounts on the CS department server.
As of 12-8-04 both Annie and I have succeeded in downloading the necessary software and logging on to our accounts and MySQL. Annie also found the table Dr. Iba created. The tables still need to be created.