CSCE 315 Lecture 4

From Notes
Jump to navigation Jump to search

« previous | Wednesday, January 25, 2012 | next »


Commenting

  • Write short summary about what a block of code does
  • Include reason if possible
  • Comment about something that is used to avoid errors (prevents code deletion
  • units for numeric data
  • range of allowable values.
  • limitations on input data.


Database Systems

Designed to manage very large amounts of data, query that data, and pull out useful information.

  • Efficiency
  • Reliability
  • Ease of access

Create structure (schema), and then populate it with data.

Entity-Relationship Model

  • Entities are things
  • Entity sets are collections of things
  • Attributes are properties of entity sets

Relationships

One-to-One
A team can have One MVP
Many-to-One
a town can have many people in it
Many-to-Many
Senators can sponsor many bills, and a bill can be sponsored by many senators

Attributes can be added to relationsips and relationships can be multi-way:

  • Person born in a hospital in a town (set of hospitals or relationship annotated with hospital name)

Generalizations: A Senator is an (isa) Elected official

Keys

Identifying a unique record by a value.

Baseball player identified by Number and Team attributes

Weak key needs help identifying:

  • Player plays on a team. Team name on Team entity, number on player.

Avoid redundant data like storing team name on the player when the player is related to a team.

Don't use a separate entity if an attribute will suffice.