32
Overview of Database Systems CSCE 315 – Programming Studio Spring 2010 Team Project 1, Lecture 1

Overview of Database Systems

Embed Size (px)

DESCRIPTION

Overview of Database Systems. CSCE 315 – Programming Studio Spring 2010 Team Project 1, Lecture 1. Project. The first team project (next week) will involve putting together a very basic database system There will be a few lectures to give you an overview of database systems - PowerPoint PPT Presentation

Citation preview

Page 1: Overview of Database Systems

Overview of Database Systems

CSCE 315 – Programming StudioSpring 2010Team Project 1, Lecture 1

Page 2: Overview of Database Systems

Project

The first team project (next week) will involve putting together a very basic database systemThere will be a few lectures to give you an overview of database systemsThis is nowhere close to what you would get in a full database courseSlides adapted from Jennifer Welch (some of hers were from Jeffrey Ullman)

Page 3: Overview of Database Systems

Database Systems

Systems designed to manage very large amounts of data, and to query that data to pull out useful informationOften, key considerations include: Efficiency Reliability Ease of access (querying, distributed)

Page 4: Overview of Database Systems

Creating a Database

A database schema determines what will be represented in the databaseThis should be tightly controlled by a database managerSpecified through a data definition language

Page 5: Overview of Database Systems

Querying Databases

Once database has been populated, users can query the dataA data manipulation language controls how the user can specify queries, (and thus what types of queries are allowed) SQL is probably the most well-known

Page 6: Overview of Database Systems

Other Database Topics

“Real” database courses include lots of other things that we’ll be ignoring here More complete theory behind design Query optimization Efficient storage Processing Transactions – grouped

queries that provide atomic operations Scheduling, logging, recovery

Page 7: Overview of Database Systems

Entity-Relationship Model

Way of expressing (in diagrammatic form) a database design Kinds of data and how they connect

Easy first way to think about databasesLater, relational model described

Page 8: Overview of Database Systems

Entities and Attributes

Entities are thingsEntity sets are collections of those thingsAttributes are properties of entity sets

Page 9: Overview of Database Systems

Entity Sets and Attributes

Senator

Name

State

Party

YearsName Text

Bill

Page 10: Overview of Database Systems

Relationships

Connect two or more entity sets

Senator

Name

State

Party

Years

Name Text

Bill

SponsoredName

Organization

Lobbyist

Wrote

Contributed

Page 11: Overview of Database Systems

Values of Relationships

The “value” of an entity set is the entities it containsThe “value” of a relationship is a list of currently related entities (one from each entity set)

Senator Bill

Smith Tax Bill

Smith Defense Bill

Jones Tax Bill

Page 12: Overview of Database Systems

Multi-Way Relationships

E.g. Lobbyist lobbied Senator about Bill

Senator

Name

State

Party

Years

Name Text

Bill

Name

Organization

LobbyistLobbied

Page 13: Overview of Database Systems

Relationship Types

Consider binary relationships (two entity groups in a relationship)One-to-one Each entity can have at most one in the

other category e.g. entity groups: Baseball player, Team relationship: Team MVP A team can only have one MVP, and a

player can only be MVP for one team.

Page 14: Overview of Database Systems

Relationship Types

Consider binary relationships (two entity groups in a relationship)One-to-oneMany-to-one Each entity of first set can go to at most one

of the second set e.g. entity groups: Person, Town relationship: BornIn A person can is born in only one town, but a

town can have many people born there

Page 15: Overview of Database Systems

Relationship Types

Consider binary relationships (two entity groups in a relationship)One-to-oneMany-to-oneMany-to-many Any number from one set to the other e.g. Senators can sponsor many bills, and

each bill can be sponsored by many Senators

Page 16: Overview of Database Systems

Diagrams of Relationships

Arrow shows “to one”

Person Town

BaseballPlayer Team

Born In

MVP

Lived In

Page 17: Overview of Database Systems

Attributes on Relationships

Can be converted to multi-way diagrams

Person TownBorn In

Hospital

Page 18: Overview of Database Systems

Attributes on Relationships

Can be converted to multi-way diagrams

Person TownBorn In

Hospital

Hospitals

Page 19: Overview of Database Systems

Attributes on Relationships

Note arrows

Person DateInjured

Hospital

Hospitals

Page 20: Overview of Database Systems

Programmer

Roles

If multiple references to same entity set, label edges by roles

StudentsTeam

Tester

Team Lead

Page 21: Overview of Database Systems

Subclass

Fewer entities, more properties

U.S.Representative District

Elected OfficialName

Party

isa

Page 22: Overview of Database Systems

Subclass

Entity in all subclasses

U.S.Representative

District

Elected Official Name

isa

Republican

District

isa

Page 23: Overview of Database Systems

Keys

A key is a set of attributes for an entity set such that no two entities agree on all the attributes.We must have a key for every entity set

U.S.Representative District

Elected Official Name

Party

isa

For an isahierarchy,only root canhave a key.

Page 24: Overview of Database Systems

Key for multiple attributes

Must choose one set of attributes

Baseball Player

FirstName

LastName

Number

Position

Nationality Salary

Birthdate

Team

Page 25: Overview of Database Systems

Key for multiple attributes

Must choose one set of attributes

Baseball Player

FirstName

LastName

Number

Position

Nationality Salary

Birthdate

Team

Page 26: Overview of Database Systems

Key for multiple attributes

Must choose one set of attributes

Baseball Player

FirstName

LastName

Number

Position

Nationality Salary

Birthdate

Team

Page 27: Overview of Database Systems

Weak entity sets

Need “help” to determine key

Baseball Player

FirstName

LastName

Number

Position

Nationality Salary

Birthdate

Name

TeamPlaysOn

City

Note arrrow:indicates manyto one.

Page 28: Overview of Database Systems

Design Techniques

Avoid redundancy Say the same thing two ways

Baseball Player

FirstName

LastName

Number

Position

TeamName

Salary

Birthdate

Name

TeamPlaysOn

City

Page 29: Overview of Database Systems

Design Techniques

Avoid redundancy Say the same thing two ways

Baseball Player

FirstName

LastName

Number

Position

TeamName

TeamTown

Birthdate

Page 30: Overview of Database Systems

Design Techniques

Don’t use entity set if attribute will doEntity lists should either Have some non-key attribute Be the “many” in a many-one/many-

many relationshipBaseball PlayerName Plays

On

Name

Team

City

Page 31: Overview of Database Systems

Design Techniques

Don’t use entity set if attribute will doEntity lists should either Have some non-key attribute Be the “many” in a many-one/many-

many relationshipBaseball PlayerName

Team

Page 32: Overview of Database Systems

Design Techniques

Don’t overuse weak entity setsUsually use unique key for each entity set (e.g. UIN, SSN, VIN)Not always possible, though