+ All Categories
Home > Documents > 24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS). DATABASE CONCEPTS Ahmad, Mohammad J. CS 101.

24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS). DATABASE CONCEPTS Ahmad, Mohammad J. CS 101.

Date post: 28-Dec-2015
Category:
Upload: heather-burke
View: 224 times
Download: 2 times
Share this document with a friend
Popular Tags:
28
24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS)
Transcript
Page 1: 24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS). DATABASE CONCEPTS Ahmad, Mohammad J. CS 101.

24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS)

Page 2: 24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS). DATABASE CONCEPTS Ahmad, Mohammad J. CS 101.

DATABASE CONCEPTS

Ahmad, Mohammad J.CS 101

Page 3: 24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS). DATABASE CONCEPTS Ahmad, Mohammad J. CS 101.

3

Graphicsheat.com

Page 4: 24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS). DATABASE CONCEPTS Ahmad, Mohammad J. CS 101.

4

WHY DO DATABASES MATTER TO YOU?

• Among non-CS people, database skills are rare• A healthy understanding of databases makes you

marketable• Almost every business has a database of some sort – and

someone has to manage it!• You could be selected to be trained by your company to

manage a database someday!

Page 5: 24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS). DATABASE CONCEPTS Ahmad, Mohammad J. CS 101.

5

IN THE BEGINNING

• Pre-1970, databases were flat

• We have essentially worked with “flat” databases:– Tab Delimited– CSV

• These databases were just text files (.txt)

Page 6: 24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS). DATABASE CONCEPTS Ahmad, Mohammad J. CS 101.

THE PROBLEM?

Lname, FName, Age, Salary|Smith, John, 35, $280|Doe, Jane, 28, $325|Brown, Scott, 41, $265|Howard, Shemp, 48, $359|Taylor, Tom, 22, $250

• A text file database, like above, is difficult to search though and find specific information

6

Page 7: 24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS). DATABASE CONCEPTS Ahmad, Mohammad J. CS 101.

AND THEN THERE WAS LIGHT

• Relational databases were created in 1970

• IBM researcher, E.F. Codd, wrote a paper describing them

• Relational databases store information in tables– For visual purposes, think similar to Excel tables

Page 8: 24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS). DATABASE CONCEPTS Ahmad, Mohammad J. CS 101.

8

RELATIONAL DATABASES ARE EVERYWHERE!

Company Inventory Tracking

Schools

Online Stores

Social Networking

Offline Stores

Healthcare

Record Keeping

Internet

Page 9: 24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS). DATABASE CONCEPTS Ahmad, Mohammad J. CS 101.

9

SAMPLE RDB

Page 10: 24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS). DATABASE CONCEPTS Ahmad, Mohammad J. CS 101.

10

LET’S BACK UP…

Page 11: 24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS). DATABASE CONCEPTS Ahmad, Mohammad J. CS 101.

11

FIELD

• The smallest data element contained in a table• Field types:

– Text– Numeric– Date

• Field examples:– Birthdates– Last Name– Age– Social Security #

Page 12: 24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS). DATABASE CONCEPTS Ahmad, Mohammad J. CS 101.

12

RECORD

• Record – a complete set of all of the data elements (fields) about one person, place, event, or concept

• Example record in a course gradebook:

– First Name, Last Name, Student ID, Age, E-mail

Page 13: 24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS). DATABASE CONCEPTS Ahmad, Mohammad J. CS 101.

13

TABLE

• The foundation of every database

• Contains a primary key (unique field)

• Is a collection of related records

– Example Table:• All Student records in my CS 101 sections would be added to my Section

Roster Table during registration

Page 14: 24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS). DATABASE CONCEPTS Ahmad, Mohammad J. CS 101.

14

KEY

• A field that contains a unique identifier

• Foreign key– A field in one table, that is a primary key in another

Page 15: 24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS). DATABASE CONCEPTS Ahmad, Mohammad J. CS 101.

15

DATABASE

• Consists of:– One or more tables to store data– One or more forms to enter data– One or more reports to output the table data as organized

information

Page 16: 24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS). DATABASE CONCEPTS Ahmad, Mohammad J. CS 101.

16

LET’S DEFINE A TABLE

• Let’s make a table for student information

– What fields?– What data types?– How do we identify records?

Page 17: 24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS). DATABASE CONCEPTS Ahmad, Mohammad J. CS 101.

17

RELATIONSHIPS

“When two tables notice each other…”

• Access is a Relational Database Management System

• That being said it’s important that, over time, we learn to create relationships effectively.

Page 18: 24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS). DATABASE CONCEPTS Ahmad, Mohammad J. CS 101.

18

RELATIONSHIP BASICS

• For now, let’s ignore how we actually make a relationship (it’s just drag and drop)

• Let’s examine some already created relationships and talk through them

Page 19: 24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS). DATABASE CONCEPTS Ahmad, Mohammad J. CS 101.

SAMPLE RELATIONSHIPS

19

Page 20: 24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS). DATABASE CONCEPTS Ahmad, Mohammad J. CS 101.

WHAT CHANGED?

Page 21: 24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS). DATABASE CONCEPTS Ahmad, Mohammad J. CS 101.

WHY IS THIS NECESSARY?

Page 22: 24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS). DATABASE CONCEPTS Ahmad, Mohammad J. CS 101.

RELATIONSHIP TYPES IDENTIFIED

• One-to-Many

• Many-to-Many***

• One-to-One

Page 23: 24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS). DATABASE CONCEPTS Ahmad, Mohammad J. CS 101.

MANY-TO-MANY?

23

Page 24: 24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS). DATABASE CONCEPTS Ahmad, Mohammad J. CS 101.

A BRIEF NOTE ON MANY TO MANY

“Think about a simple relationship like the one between Authors and Books. An author can write many books. A book could have many authors. Now, without a bridge table to resolve the many-to-many relationship, what would the alternative be? You'd have to add multiple Author_ID columns to the Books table, one for each author. But how many do you add? 2? 3? 10? However many you choose, you'll probably end up with a lot of sparse rows where many of the Author_ID values are NULL and there's a good chance that you'll run across a case where you need "just one more." So then you're either constantly modifying the schema to try to accommodate or you're imposing some artificial restriction ("no book can have more than 3 authors") to force things to fit.”

-Joe Stefanelli on StackOverflow.com

Page 25: 24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS). DATABASE CONCEPTS Ahmad, Mohammad J. CS 101.

25

REFERENTIAL INTEGRITY

• For relationships, you want to be able to be absolutely sure that they are valid.

• What if you had a business, and didn’t check that the people you wrote checks to were employees?

Page 26: 24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS). DATABASE CONCEPTS Ahmad, Mohammad J. CS 101.

26

WHAT COULD HAPPEN?

Page 27: 24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS). DATABASE CONCEPTS Ahmad, Mohammad J. CS 101.

27

CASCADE UPDATES / DELETES

• Cascading Updates (Good)– Typically, we will always cascade updates. Let’s assume we

change the stock number of an item, all orders that referenced that stock number would automatically update (for record keeping information).

• Cascades Deletes (Bad.. Well, generally)– Let’s assume an employee is working on some big projects.

The HR department accidentally removes the employee… every project in the database, that refers to the deleted employee, will be deleted.

Page 28: 24 GOLDEN COINS, 1 IS FAKE ( WEIGHS LESS). DATABASE CONCEPTS Ahmad, Mohammad J. CS 101.

SPREADSHEET VS DATABASES

MS Excel

• Only need one worksheet to manage data

• Have mostly numeric data (i.e. expense reports)

• Require subtotals and totals in your worksheet

• Want to run a series of “What-If” Scenarios

• Need to create complex charts or graphs

MS Access

• Require multiple related tables to store data

• Have a large amount of data• Need to connect to and send/receive

data to/from external databases• Need to group, sort, and total data

based on various parameters• Have an application that requires

multiple users to connect to one data source at once

28


Recommended