ER-modelling

  1. You are to plan a small student database. Following things are required:
  2. So, let's draw the ER-diagram describing the database.
  3. Entities

    First, find all the obvious entities.
  4. Start Microsoft Excel. You'll find yourself drawing the diagram using the drawing tool in Excel.
  5. Relationships

    Next we'll trouble our minds about the relationships between the entities.
  6. Draw a diamod shaped figure to describe one of the relationships. Write "takes an exam" (tenttii) inside the figure and align the text to the center. Copy the formatted figure for every relationship.
  7. Put the takes an exam relationship between the entities Student and Course. Connect the relationsip to the entities with the line that you'll find under the Autoshapes|Connectors menu.
    Opiskelija tenttii kursseja
  8. Connect the other relationships and entities in the same way (järjestää = organizes, kuuluu = belongs to).
    Kohteet ja niiden väliset suhteet
  9. Cardinalities

    Cardinality indicates the amount of relationships an entity can have. The options are: In the database you are working on, the cardinalities go as follows: Mark the cardinalities to your ER diagram by writing either 1 or M between te entities (depending on the relationship, of course). Use the TextBox tool in Excel.
    Kardinaalisuus
  10. Attributes (Properties)

    Next step: Add the attributes belonging to every entity end relationship.
  11. Attributes are shown inside ellipses that are connected to the entity or the relationship with a line. Parts of the composite attributes have their own ellipses each and they are in turn connected to the composite attribute. Multi-valued attributes have double edges on their ellipses. Add all the attributes to you diagram. (Sähköpostiosoite = e-mail address, name = nimi, sukunimi = last name, etunimi = first name, puhelinnumero = phone number)

    Attributes connected to an entity

    Ominaisuus

    Composite attribute

    Koostettu ominaisuus

    Multi-valued attribute

    Moniarvoinen ominaisuus
  12. Keys

    The attributes that uniquely identify an entity must be selected as candidate keys. When weak entities or relationships containing attributes are in question it may happen that their own attributes are not enough to identify them. Then some entites connected to these problematic items should be included in the key. The best of all candidates should be selected as the key. The best one is usually the smallest in size and the one that is most likely to stay unique. In order to improve the performance of the database, it is sometimes clever to create a new attribute that only serves as a key.
  13. Datatypes

    A datatype needs to be defined for every attribute. When selecting a datatype it is common to reserve the space for the data as well. Attention should be payed for reserving the space as there is nothing as annoying as too short a field for your last name... A datatype can be: Write the attributes associated with every entity as small tables that have the name of the entity as the title. Write down the datatype, possible default value and possible restrictions and other remarks. You can underline or mark the key(s) in some other way. Restrictions that can come into question are for example

    Course

    AttributeDatatypeRequiredDefault valueRestrictions
    CodeCHAR(6)Yes The first three characters are letters and the last three are numbers.
    NameVARCHAR(64)Yes  
    CreditsFLOATYes1Only integers and halves.
  14. Save your ER diagram to drive U: to folder databases (tietokannat) as demo1.xls.
  15. You own a company where every member of the personnell has a special professional title like the project manager or programmer or whatever. The staff participates in different projects. Every project has an orderer, one or several managers and employer or employers. Employers in the project are also classified by their job (programming, designing, testing etc.). Starting and finishing dates as well as a name are also associated with a project. The names of the staff and their phone numbers and e-mail addresses are also wanted in the database. Plan and draw an ER diagram of a database for your company. You can use the same Excel workbook as in previous exercise but use another worksheet.
    1. Find and draw the entities
    2. Draw the relationships
    3. Define cardinalities
    4. Add the attributes to the entities and relationships
    5. Select the keys
    6. Define the datatypes, requirednesses, default values and restrictions for the attributes
  16. Ask the teacher (the person hanging around in the computer lab hoping someone to ask something) to check your diagram. Make corrections if necessary. Remember to save!
  17. You are organizing a soccer tournament. What kind of a database would you need to help you? Write a list of the requirements including the properties needed in the database system and the data that needs to be recorded in it. Write it to a new worksheet and let the teacher check your list.
  18. Draw an ER diagram based on your requirements and again, let the teacher check it.
  19. Some examples for good solutions to this week's exercises will be handed out next week.

http://appro.mit.jyu.fi/2001/kevat/tietokannat/demot/demo1/index.html
© Tommi Lahtonen ()<URL: http://www.iki.fi/hazor/>
9.03.2001 17:59:14