day 12: databases rahul kavi [email protected] [email protected] october 3, 2013 1

12
DAY 12: DATABASES RAHUL KAVI [email protected] October 3, 2013 1

Upload: phyllis-lambert

Post on 13-Dec-2015

217 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: DAY 12: DATABASES RAHUL KAVI Rahul.Kavi@mail.wvu.edu Rahul.Kavi@mail.wvu.edu October 3, 2013 1

DAY 12:DATABASES

RAHUL [email protected]

October 3, 2013

1

Page 2: DAY 12: DATABASES RAHUL KAVI Rahul.Kavi@mail.wvu.edu Rahul.Kavi@mail.wvu.edu October 3, 2013 1

2

DATABASES

• A database is an organized collection of data

• There are many types of databases– Flat File– XML– Workbooks– Relational– Key-Value Store

Page 3: DAY 12: DATABASES RAHUL KAVI Rahul.Kavi@mail.wvu.edu Rahul.Kavi@mail.wvu.edu October 3, 2013 1

3

WHERE ARE DATABASES USED?

• Storing bank records, corporate data, etc.• Storing login credentials for websites/blogs.• Store content of popular websites like

Flickr.com, YouTube.com, etc.• Store content of popular services like

Netflix, Instagram, Pandora, iTunes, Spotify, Game Center (iOS), App Store, Play Store (Android App Store).

Page 4: DAY 12: DATABASES RAHUL KAVI Rahul.Kavi@mail.wvu.edu Rahul.Kavi@mail.wvu.edu October 3, 2013 1

4

RELATIONAL DATABASES

• Access is a relational database– A relational database is a collection of data

items organized as a set of formally described tables.

– Data stored in tables.– In addition to table definitions, there are also

relationships between tables

Page 5: DAY 12: DATABASES RAHUL KAVI Rahul.Kavi@mail.wvu.edu Rahul.Kavi@mail.wvu.edu October 3, 2013 1

5

EXCEL VS ACCESS

• Excel: Spreadsheet application to arrange, and analyze data in sheets. Sheets have no relation enforced with each other. May have duplicate data.

• Access: Database application to store, retrieve, edit, delete, add data (using relationships between data). We can enforce relation between tables you can avoid redundant data.

Page 6: DAY 12: DATABASES RAHUL KAVI Rahul.Kavi@mail.wvu.edu Rahul.Kavi@mail.wvu.edu October 3, 2013 1

6

RELATION BETWEEN TABLES?

• Example: Table Name: UserTable

Contents/Fields of UserTable: (username, password)

Username: String/Character data (includes special characters)

Password: String/Character data

• Other examples:– iTunes Account ---> Apple ID <---- App Store account.– Mix Email Account --> My ID <---- WVU WiFi

• There is a user table for each of the above accounts.

Page 7: DAY 12: DATABASES RAHUL KAVI Rahul.Kavi@mail.wvu.edu Rahul.Kavi@mail.wvu.edu October 3, 2013 1

7

RECORDS AND FIELDS REVIEW

• A single entry in a table is called a “record” (horizontal entries/rows)

• Each piece of data in a record is a “field” (vertical column names/column).

Page 8: DAY 12: DATABASES RAHUL KAVI Rahul.Kavi@mail.wvu.edu Rahul.Kavi@mail.wvu.edu October 3, 2013 1

8

CASCADING

• Example of a Cascade Delete:

If you delete your Google account, you lose access to YouTube, Gmail, etc. Your ability to login is lost across all Google Services.• Example of a Cascade Update: If you

lose your credit card and get a new one, your information is updated (not deleted) across all of your services (provided by credit card company).

Page 9: DAY 12: DATABASES RAHUL KAVI Rahul.Kavi@mail.wvu.edu Rahul.Kavi@mail.wvu.edu October 3, 2013 1

9

OPEN ACCESS

• Start->Access-> Blank desktop database.

• Enter name of the database “Day1Access_LastName_FirstName.

• Click create.

Page 10: DAY 12: DATABASES RAHUL KAVI Rahul.Kavi@mail.wvu.edu Rahul.Kavi@mail.wvu.edu October 3, 2013 1

10

DESIGN TABLE• Right click on Table 1 tab.• Click design.• Enter “UserName” (no spaces between

words).• Ensure UserName is a primary key.• Field Name 1: “NameOfUser”• Data Type: “Short Text”.• Field Name2: “Password”.• Data Type: “Short Text”.

Page 11: DAY 12: DATABASES RAHUL KAVI Rahul.Kavi@mail.wvu.edu Rahul.Kavi@mail.wvu.edu October 3, 2013 1

11

DATASHEET VIEW• Right click on Table 1 tab.• Click datasheet view.• Enter 5 usernames and passwords.• Try entering duplicate usernames.

Page 12: DAY 12: DATABASES RAHUL KAVI Rahul.Kavi@mail.wvu.edu Rahul.Kavi@mail.wvu.edu October 3, 2013 1