Lab 1 - Getting Started / Database Fundamentals


Objectives
  1. Review Lab 0.
  2. Familiarize ourselves with Piazza.
  3. Familiarize ourselves with how to submit files on Apollo.
  4. Reinforce concepts related to different types of keys.
  5. Discuss a real-world database application.


Lab 0 Reminders
  1. If you haven't already done so, please complete Lab 0 later today.
  2. If you haven't setup your CS account, you should do so now.

Piazza

Piazza is a social network site developed to facilitate communication between students, teaching fellows, and professors.

You can access Piazza here.

There are some really cool features of Piazza that we want to emphasize:

  • Anonymous Posts
  • Private Posts
  • Customizable Notifications: emails, apps, etc
  • Extremely Fast Response Time

Practice Using Apollo

This is where you will be submitting your homework: Apollo

Please complete the following to familiarize yourself with the procedure:

  1. Open up Notepad or WordPad from the Accessories folder on Windows
  2. Type "Hello, World!" in a new text file. Make sure that you create a plain-text file for all of your homework files.
  3. Save the file on your desktop as lab1.txt. Make sure to use the exact file name, or Apollo will not accept your file.
  4. Login to Apollo. You will need to use your Kerberos username and password.
  5. Find the appropriate lab section on the Apollo main page and click Upload files.
  6. For each file that you want to submit, find the matching upload section for the file. Make sure that you use the right section for each file. You may upload any number of files at a time.
  7. Click the Upload button at the bottom of the page.
  8. Review the upload results. If Apollo reports any issues, return to the upload page by clicking the link at the top of the results page, and try the upload again, per Apollo’s advice.
  9. Once all of your files have been successfully uploaded, return to the upload page by clicking the link at the top of the results page. The upload page will show you when you uploaded each file, and it will give you a way to view or download the uploaded file. Click on the link for each file so that you can ensure that you submitted the correct file.
  10. Use the text editor to change the content of the file to "Oh Hey!", resubmit it following the steps above, and view it again.


Practice Exercise: Understanding keys and constraints

Consider the following instances of three relations:

      Passenger       Flight       BookedOn
     
id name city
001 Tom Brady San Mateo, CA
002 David Ortiz Santo Domingo, Dom. Rep
003 Kevin Youkilis Cincinnati, Oh
004 Ray Allen Riverside, CA
005 Kevin Garnett Greenville, SC
006 Zdeno Chara Trencin, SVK
     
number origin destination
DL5882 Boston, MA Indianapolis, IN
BA215 London, United Kingdom Boston, MA
AA573 Boston, MA Miami, FL
LH422 Frankfurt, Germany Boston, MA
UA717 Boston, MA Los Angeles, CA
UA898 Beijing, China Boston, MA
     
person flight
005 UA898
002 AA573
005 UA717
006 BA215
001 DL5882
004 DL5882

Notes:

  • Every person in the Passenger relation has a unique value for the id attribute.
  • Every flight in the Flight relation has a unique value for the number attribute.
  • The BookedOn relation captures the relationships between people and the flights on which they are booked.
    • Example: the tuple (001, DL5882) in BookedOn tells us that Tom Brady (001) is booked on a flight from Boston to Indianapolis (DL5882).
Given these relations, answer each of the following questions:
  1. Select a possible primary key for each of these relations.
  2. Is the combination (number, origin) a key for the Flights relation?
  3. Is the combination (number, origin) a candidate key for the Flights relation?
  4. Two of the attributes in these relations appear to be foreign keys. Which ones?
  5. Say that you were inserting a row into any of the tables above, and that row violated the uniqueness constraint, give an example of what that row would look like.
  6. Say that you were inserting a row into any of the tables above, and that row violated the referential integrity constraint, give an example of what that row would look like.


Practice Exercise: A Real-World Database Application

Imagine that you've just been hired to create a real-world database application, an online catalog for a library.

  1. Describe the types of data that could be stored in this type of database.
  2. Give your client an example of how transactions would be helpful for this application.
  3. Explain to your client what advantages a database system might have in this context.
    • Hint: think about the four key DBMS functions mentioned in the lecture notes on database fundamentals.
  4. Develop at 3-5 schema for tables that you might use for this application.
    • Hint: remember that schemas contain the tables name and the names of each column in that table
    • Pro-tip: keep your table and column names succint, such as: Car(color, make, model, num_doors)
    • Hint: tables will generally either describe:
      • Entities - such as Passenger or Flight
      • Relationships between Entities - such BookedOn
  5. For each table, which field would you pick as a primary key?
    • Example: if we have a table of students, the BU id number can serve as a primary key
  6. Briefly explain to your client what primary and foreign keys are, and how they are used in this application.

CS105