day 9: databases rohit [email protected] [email protected] september 21, 2015 1

22
DAY 9: DATABASES Rohit [email protected] September 21, 2015 1

Upload: cuthbert-sanders

Post on 18-Jan-2016

225 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: DAY 9: DATABASES Rohit Rorohit@mix.wvu.edu Rorohit@mix.wvu.edu September 21, 2015 1

DAY 9:DATABASES

[email protected]

September 21, 2015

1

Page 2: DAY 9: DATABASES Rohit Rorohit@mix.wvu.edu Rorohit@mix.wvu.edu September 21, 2015 1

2

SCENARIO MANAGER

• Scenario Manager is a what-if analysis tool that allows you to define up to 32 scenarios to compare their effects on calculated results

• Data->Data Tools->What-If Analysis->Scenario Manager

• Example: Profit calculations for a business based on units sold, production cost per unit, shipping cost per unit

Page 3: DAY 9: DATABASES Rohit Rorohit@mix.wvu.edu Rorohit@mix.wvu.edu September 21, 2015 1

3

ADDING SCENARIOS

• Data->Data Tools->What-If Analysis->Scenario Manager

• Add…– Scenario name– Changing cells– Set values for each cell

• Example:– Best Case: 75,000 units, $38/unit production cost,

$0.30/unit shipping cost– Likely Case: 50,000, $42.95, $0.5– Worst Case: 25,000, $48, $0.75

Page 4: DAY 9: DATABASES Rohit Rorohit@mix.wvu.edu Rorohit@mix.wvu.edu September 21, 2015 1

4

WORKING WITH SCENARIOS

• Delete• Edit• Show• Summary

– Regular summary– PivotTable summary

Page 5: DAY 9: DATABASES Rohit Rorohit@mix.wvu.edu Rorohit@mix.wvu.edu September 21, 2015 1

5

SOLVER

• Solver is similar to goal seek, but it allows multiple input values to change

• Solver is an Add-In, so it must be loaded before you can use it– File->Options->Add-Ins->Manage: Excel Add-

Ins-> Go…– Check “Solver Add-in”-> OK

Page 6: DAY 9: DATABASES Rohit Rorohit@mix.wvu.edu Rorohit@mix.wvu.edu September 21, 2015 1

6

DATABASES

• A database is an organized collection of data

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

Page 7: DAY 9: DATABASES Rohit Rorohit@mix.wvu.edu Rorohit@mix.wvu.edu September 21, 2015 1

7

POPULAR DROP-OUT BILLIONAIRES (IMPORTANCE OF COMPUTER SKILLS)

Page 8: DAY 9: DATABASES Rohit Rorohit@mix.wvu.edu Rorohit@mix.wvu.edu September 21, 2015 1

8

WHY LEARN THESE SKILLS?

• Database skills are an essential part of basic computer skills like Programming.

• Limitless possibilities with a 800$ computer from the comfort of home (consume or produce).

• Create own website/blog (commercial, personal).

• Computer skills like Programming, Database Management, Blogging are like culinary skills.

• Business Plan competition.

Page 9: DAY 9: DATABASES Rohit Rorohit@mix.wvu.edu Rorohit@mix.wvu.edu September 21, 2015 1

9

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 10: DAY 9: DATABASES Rohit Rorohit@mix.wvu.edu Rorohit@mix.wvu.edu September 21, 2015 1

10

WHERE ARE DATABASES USED?

Source: oracle.com

Page 11: DAY 9: DATABASES Rohit Rorohit@mix.wvu.edu Rorohit@mix.wvu.edu September 21, 2015 1

11

RELATIONAL DATABASES

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

items organized as a set of formally described tables from which data can be accessed easily

– In addition to table definitions, there are also relationships between tables

Page 12: DAY 9: DATABASES Rohit Rorohit@mix.wvu.edu Rorohit@mix.wvu.edu September 21, 2015 1

12

RECORDS AND FIELDS REVIEW

• A single entry in a table is called a “record”– A record (row) is one or more pieces of data about

a single entity

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

• A table definition lists all the fields the records in that table have– The definition can define default values for fields– Some fields are required for each record, others

are optional

Page 13: DAY 9: DATABASES Rohit Rorohit@mix.wvu.edu Rorohit@mix.wvu.edu September 21, 2015 1

13

KEYS

• Each table has to have a “primary key”. This is a field, or a combination of fields that will be unique to each record

• Keys allow you to identify a particular record

• You can use the key in other tables to reference the record

Page 14: DAY 9: DATABASES Rohit Rorohit@mix.wvu.edu Rorohit@mix.wvu.edu September 21, 2015 1

14

INDEXES

• Indexes are an ordering of a key or other field that is computed on creation and kept up to date as the database is updated

• By using the index, the database software is able to quickly retrieve the record given the field value

Page 15: DAY 9: DATABASES Rohit Rorohit@mix.wvu.edu Rorohit@mix.wvu.edu September 21, 2015 1

15

RELATIONSHIPS

• By including a the key from one table as a field in a different table, we create a relationship between the two tables

• This allows us to link the data between two tables

• In the second table, the field is known as a “foreign key”

Page 16: DAY 9: DATABASES Rohit Rorohit@mix.wvu.edu Rorohit@mix.wvu.edu September 21, 2015 1

16

EXAMPLE

• Two tables: People, PhoneNumbers– People: id, first_name, last_name, birthdate– PhoneNumbers: id, country_code, area_code,

number, person_id

• PhoneNumbers.person_id would hold the same value as People.id for phone numbers that belong to the given person

Page 17: DAY 9: DATABASES Rohit Rorohit@mix.wvu.edu Rorohit@mix.wvu.edu September 21, 2015 1

17

CASCADING

• If the records with the foreign key are only used as an extension of the original table, you may want to cascade updates and/or deletes– Deletes: If the original record is deleted, the

foreign key record is deleted– Updates: If the key of the original record is

changed, the foreign key is updated to match

Page 18: DAY 9: DATABASES Rohit Rorohit@mix.wvu.edu Rorohit@mix.wvu.edu September 21, 2015 1

18

PLANNING DATABASES

• Define what tables you need• Define what fields belong in each table• Define what data types each field should

be• Define default values for each field• Choose between required and optional

Page 19: DAY 9: DATABASES Rohit Rorohit@mix.wvu.edu Rorohit@mix.wvu.edu September 21, 2015 1

19

NORMALIZATION

• Normalization is a process of organizing fields and tables to minimize redundancy of data– DRY (don’t repeat yourself)– If you repeat yourself, when you need to

make a change you have to change it everywhere or you will have problems

Page 20: DAY 9: DATABASES Rohit Rorohit@mix.wvu.edu Rorohit@mix.wvu.edu September 21, 2015 1

20

SQL

• SQL is structured query language• SQL is how Access interacts with data under the

hood• INSERT INTO ‘table’ (‘field1’, ‘field2’) VALUES

(‘value1’, ‘value2’)• UPDATE ‘table’ SET ‘field1’ = ‘value1’ WHERE

‘field2’ = ‘value2’• DELETE FROM ‘table’ WHERE ‘field’ = ‘value’• SELECT ‘field1’ FROM ‘table’ WHERE ‘field2’ =

‘value’

Page 21: DAY 9: DATABASES Rohit Rorohit@mix.wvu.edu Rorohit@mix.wvu.edu September 21, 2015 1

21

COMMON EXCEL ISSUES

• Switch Row/Column• Merge (but not center)• Relative/Absolute/Mixed References

Page 22: DAY 9: DATABASES Rohit Rorohit@mix.wvu.edu Rorohit@mix.wvu.edu September 21, 2015 1