Lab 1 - Getting Started / Database Fundamentals
|
Objectives
- Review Lab 0.
- Familiarize ourselves with Piazza.
- Familiarize ourselves with how to submit files on Apollo.
- Reinforce concepts related to different types of keys.
- Discuss a real-world database application.
Lab 0 Reminders
- If you haven't already done so, please complete Lab 0 later today.
- 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:
- Open up Notepad or WordPad from the Accessories folder on Windows
- Type "Hello, World!" in a new text file.
Make sure that you create a plain-text file for all of your
homework files.
- Save the file on your desktop as
lab1.txt .
Make sure to use the exact file name, or
Apollo will not accept your file.
- Login to
Apollo.
You will need to use your Kerberos username and password.
- Find the appropriate lab section on the Apollo main page and
click Upload files.
- 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.
- Click the Upload button at the bottom of the page.
- 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.
- 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.
- 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:
- Select a possible primary key for each of these relations.
- Is the combination (number, origin) a key
for the Flights relation?
- Is the combination (number, origin)
a candidate key
for the Flights relation?
- Two of the attributes in these relations
appear to be foreign keys. Which ones?
- 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.
- 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.
- Describe the types of data that could be stored in this type of database.
- Give your client an example of how transactions would be helpful for this application.
- 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.
- 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
- 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
- Briefly explain to your client what primary and foreign keys are, and how they are used in this application.
CS105
|