ch. 15 fit5, cis 110 13f

Post on 14-Dec-2014

276 Views

Category:

Education

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

 

TRANSCRIPT

Chapter 15Introduction to Database Concepts

Read pp. 457-488 only

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Differences Between Tables and Databases

• When we think of databases, we think of tables of information:

– iTunes shows the title, artist, running time on a row

row = a record (noun) for a track

column = property

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Differences Between Tables and Databases

• When we think of databases, we think of tables of information:

– Your car’s information is one line in the state’s database of automobile registrations

row = a record for a car

column = property

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Differences Between Tables and Databases

Rows = RecordsCols = Properties

Record a.k.a. Entity, Instance, Object

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Canada’s Demographic Information

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

The Database’s Advantage

• Metadata is the key advantage of databases over other approaches to recording data as tables

– Database software can search for the <country> tag surrounding Canada

– Metadata: Data about Data

Metadata == Semantic Markup

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

The Database’s Advantage

• The tags for the CIA database fulfill two key metadata roles:

– Define the identity of the data (-> instance, entity, object)

– Define the affinity of the data (-> properties)

Tags enclose all data that is logically related.

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

The Database’s Advantage

• <country>, <population>, and similar tags have the role of identification because they label content – instance, entity, object

• <demogData> tag has the role of implementing affinity because it groups an entity’s properties

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

XML: Extensible Markup Language

• XML is a Meta-language: a language for creating new markup languages– Use XML to create custom Tag sets

• All markup languages are self-describing languages

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Rules for Writing XML

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

XML Example

• Scenario:– Create a database for the Windward Islands

archipelago in the South Pacific– Plan what information will be stored– Develop those tags:

<archipelago> <island> <iName> Tahiti </iName> <area>1048</area> </island>⁞</archipelago>

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

XML Example

• Scenario:– Create a database for the Windward Islands

archipelago in the South Pacific– Plan what information will be stored– Develop those tags:

<archipelago> <island> <iName> Tahiti </iName> <area>1048</area> </island>⁞</archipelago>

Affinity role

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

New root element

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Attributes in XML

• XML tags can have attributes

– Tag attribute values can be enclosed either in paired single or paired double quotes

– Use attributes for metadata, not for content

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Effective Design with XML Tags

• Identity Rule: Label Data with Tags Consistently

– You can choose whatever tag names you wish to name data, but once you’ve decided on a tag for a particular kind of data, you must always surround that kind of data with that tag.

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Effective Design with XML Tags

• Affinity Rule: Group Related Data

– Enclose in a pair of tags all tagged data referring to the same entity, instance, object

– Grouping makes an association of the tagged data items as being related

=> properties of the entity.

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Effective Design with XML Tags

• Collection Rule: Group Related Instances

– When you have several instances of the same kind of data, enclose them in tags

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Effective Design with XML Tags

• Group Related Instances

– A group of five islands were grouped inside an <archipelago> tag

– A group of two archipelagos were grouped inside a <geo_feature> tag

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Relational Data & RDBMS

• Relational databases – data are stored in tables (relations) in a db.

– A table stores information in rows (records) and columns (fields, properties).

– Relational databases include a Structured Query Language (SQL)

=> application programming interface (API)

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Relational Data & RDBMS

• Developed in the 1970s, relational databases are based on an underlying mathematical model, have great expressive power and are a core computer science technology that has migrated to all fields.

• The RDBMS market is dominated by Oracle, IBM DB2, and Microsoft SQL Server, which account for 85% of worldwide RDBMS revenue.

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Relational Data & RDBMS

• RDBMS Advantages: Power, speed, reliability, concurrency, abstraction, scalable.

• RDBMS in the CIT curriculum:CIT 281: MySQL intro; NoSQL intro.CIT 381: Database DesignCIT 382: Data-APIs & Cloud ComputingCIT 383: Networked Databases & Infrastructure Security

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Entities

• An entity is anything that can be identified by a fixed number of its characteristics (attributes)– The attributes have names and values– The values are the data that is stored in the

table• In relational databases, an attribute is a

“column of a table”

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Entities

• The tag used in affinity is the entity’s name• The tags within are its attributes

– “island” is an entity– “name”, “area”, and “elevation are the

attributes – “archipelago” is also an entity

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Table Instance for Island Entity

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Database Schemas

• Tags are a cumbersome way to define a table

• Database systems specify a table as a database scheme or database schema

• The schema is a collection of table definitions that gives the name of the table, lists the attributes, their data types, and identifies the primary key

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Database Schema for Island Table

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Database Schema for Nations Table

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Operations on Tables• Select • Project• Union• Difference• Product

These are generic operations that SQL implements with slightly different commands

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Case Study: MySQLOpen-Source RDBMS

• MySQL is a widely used open source RDBMS

• It is named after co-founder Michael Widenius' daughter, My.

• SQL stands for Structured Query Language

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Connecting to MySQL

• Creating MySQL databases and tables requires communicating with a MySQL server

• CIS 110 uses SQL Fiddle to run MySQL in the browser

• CIT 281: install MySQL on your own virtual machine (AWS EC2)

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Connecting to MySQL

• MySQL Terminal

– command-line interface for interacting with the MySQL server

– Demo: MySQL Terminal on shell.uoregon.edu

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Select Operation

• SELECT * FROM Nations;

• SELECT Name, Capital FROM Nations;

• SELECT Name FROM Nations WHERE Interest=‘Beach’;

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Operations on Tablesin MySQL

Ch. 15 describes five general operations on tables: Select, Project, Union, Difference, and Product

In MySQL, the first two are implented using the SELECT command.

The second two use commands that operate on two tables and will not be covered in CIS 110

Wednesday, April 9, 14

Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Learning MySQL

You will learn how to use MySQL in your Week 8 lab.

Blackboard > Weekly Labs > Lab Week 8: LM: MySQL

Wednesday, April 9, 14

top related