Database course
Download
1 / 50

Database Course - PowerPoint PPT Presentation


Database Course. General Information. TAs : Gideon Rothschild, office hours: Sun 16:00-17:00 at Ross 109 Aron Matskin, office hours: TBA Course Homepage: http://www.cs.huji.ac.il/~db Course Email: db@cs.huji.ac.il Moderated Newsgroup: local.course.db.ta

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Database Course ' - Sharon_Dale


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

General information l.jpg
General Information

  • TAs:

    • Gideon Rothschild, office hours: Sun 16:00-17:00 at Ross 109

    • Aron Matskin, office hours: TBA

  • Course Homepage: http://www.cs.huji.ac.il/~db

  • Course Email: db@cs.huji.ac.il

  • Moderated Newsgroup: local.course.db.ta

  • Students Newsgroup: local.course.db.stud


Ta lectures l.jpg
TA Lectures

  • Tue – Wed – Sun cycle

  • Same TA during the cycle

  • If a TA lecture falls out on a holiday, students should plan to attend another lecture during the same cycle

  • Students are responsible for all the material for the final exam. That includes lectures, TA lectures, slides, and homework


Assignments 1 l.jpg
Assignments (1)

  • About10-12 assignments

  • Assignments are 25% of the final grade

  • All assignments must be handed in!

  • Assignments are to be done alone (not in pairs)!

  • Must include name, login, student number. Points will be taken off if login is omitted


Assignments 2 l.jpg
Assignments (2)

  • Assignment submission:

    • Theoretical assignments - box in Ross -2

    • Programming assignments - electronically

  • Assignments are returned in Ross –2, grades available on the internet

  • Make sure that you have a grade when the exercise is returned!


Appeals and extensions l.jpg
Appeals and Extensions

  • Appeals are submitted to box in Ross -2

  • Appeal form available on the course site

  • Appeals should be submitted no later than 1 week after assignments are returned

  • Extensions are possible in special cases (i.e., miluim, childbirth, etc.).

  • Ask for the extension before the due date


Course books l.jpg
Course Books

  • Database Management Systems, by Raghu Ramakrishnan

  • Principles of Database and Knowledge-Base Systems, Volumes I and II, by Jeffery Ullman (essentially chapter 7 concerning Design Theory)

  • Oracle 8i: The Complete Reference, by Kevin Loney and George Koch


Entity relationship diagrams l.jpg

Entity-Relationship Diagrams

Database Course, Fall 2005


Scenario l.jpg
Scenario

  • http://www.imdb.com wants to maintain a movie database

  • The design approach we now consider:

    • Conceptual Database Design: high level description of data to be stored (ER model)

    • Logical Database Design: translation of ER diagrams into a relational database schema (description of tables)


Movie database requirements 1 l.jpg
Movie Database Requirements (1)

  • For actors and directors, we want to store their name, a unique identification number, address, and birthday

  • For actors, we also want to store a picture

  • For movies, we want to store the title, year of production, and type

  • We want to know who directed and who acted in each movie. Every movie has one director

  • We store the pay of each actor for each movie


Movie database requirements 2 l.jpg
Movie Database Requirements (2)

  • An actor can receive an award for his part in a movie. We store information about who got which award for which movie, along with the name of the award and year.

  • We also store the name and telephone number of the organization that gave the award. Two different organizations can give an award with the same name. A single organization does not give more than one award with a particular name in the same year.


Entities entity sets l.jpg
Entities, Entity Sets

  • Entity (ישות): An object in the world that can be distinguished from other objects

  • Entity set (קבוצת ישויות): A set of similar entities

     Entity sets are drawn as rectangles

  • Compare to objects and classes in OOD

    Q: What are some of the entity sets in our movie database?


Attributes l.jpg
Attributes

  • Attributes (תכונות): Used to describe entities

    • All entities in the set have the same attributes

    • Attributes are drawn using ovals

    • A minimal set of attributes that uniquely identify an entity is called a key

    • The names of the attributes which make up the key are underlined


Example l.jpg
Example

birthday

id

Actor

name

address


Another option for a key l.jpg

birthday

id

Actor

name

address

Another Option for a Key?


Relationships relationship sets l.jpg
Relationships, Relationship Sets

  • Relationship (קשר): Association among two or more entities

    • Relationships may have attributes

  • Relationship Set (קבוצת קשרים): Set of similar relationships

    • Relationship sets are drawn using diamonds

      Q: Could you name some of the relationship sets in the movie database?


Example17 l.jpg

salary

Example

title

birthday

id

Movie

Actor

year

Acted In

name

type

address

Where does the salary attribute belong?


Recursive relationships l.jpg
Recursive Relationships

  • An entity set can participate more than once in a relationship

  • In this case, we add a description of the role to the ER-diagram

phone number

manager

id

Employee

Manages

worker

name

address


N ary relationship l.jpg
n-ary Relationship

  • An n-ary relationship set R involves exactly n entity sets: E1, …, En

  • Each relationship in R involves exactly n entities: e1ÎE1, …, enÎ En

  • Formally, R E1x …x En

Director

id

name

id

Actor

Movie

Produced

title

name


Another option remember recursive relationships l.jpg

id

director

actor

produced

Person

Movie

title

name

Another Option: Remember Recursive Relationships


Binary vs ternary relationship l.jpg
Binary vs. Ternary Relationship

שם מוסד

מוסד

לימד

קורס

מרצה

שם קורס

מספר קטלוגי

מס זהות

שם מרצה

שם מוסד

לימד ב

ניתן ב

מוסד

לימד את

קורס

מרצה

שם קורס

מספר קטלוגי

מס זהות

שם מרצה


Important note l.jpg

Role

title

role

Important Note

  • The entities in a relationship set identify the relationship

  • Suppose we wanted to store the role of an actor in a movie

  • How would we store information about a person who acted in one movie in several roles?

id

Actor

Movie

Acted In

title

name


Key constraints l.jpg
Key Constraints (אילוצי מפתח)

  • Key constraints specify whether an entity can participate in one, or more than one, relationships in a relationship set

  • When there is no key constraint, an entity can participate any number of times

  • When there is a key constraint, the entity can participate at most one time

     Key constraints are drawn using an arrow from the entity set to the relationship set


Many to many l.jpg
Many-to-Many

  • A movie is directed by any number of directors

  • A director can direct any number of movies

id

Director

Movie

Directed

title

name

Director

Directed

Movie


One to many l.jpg
One-to-Many

  • A movie is directed by at most one director

  • A director can direct any number of movies

id

Director

Movie

Directed

title

name

Director

Directed

Movie


One to one l.jpg
One-to-One

  • A movie is directed by at most one director

  • A director can direct at most one movie

id

Director

Movie

Directed

title

name

Director

Directed

Movie


Another example l.jpg
Another Example

Where would you put the arrow?

age

father

id

Person

FatherOf

child

name


Another example28 l.jpg
Another Example

age

father

id

Person

FatherOf

child

name


Key constraints in ternary relationships l.jpg
Key Constraints in Ternary Relationships

Actor

id

name

id

Director

Movie

produced

title

name

What does this mean?

A movie has at most one actor and one director


Participation constraints l.jpg
Participation Constraints אילוצי השתתפות))

  • When there is no participation constraint, it is possible that an entity will not participate in a relationship set

  • When there is a participation constraint, the entity must participate at least once

     Participation constraints are drawn using a thick line from the entity set to the relationship set


Example 1 l.jpg
Example (1)

  • A movie has at least one director

  • A director can direct any number of movies

id

Director

Movie

Directed

title

name

Do you think that there should be a participation constraint from Director to Directed?

Director

Directed

Movie


Example 2 l.jpg
Example (2)

  • We can combine key and participation constraints.

  • What does this diagram mean?

id

Director

Movie

Directed

title

name

A movie has exactly one director.

A director directs at least one movie.


Weak entity sets 1 l.jpg

organization

Award

name

year

Weak Entity Sets (1)

What is the problem here?


Weak entity sets 2 l.jpg
Weak Entity Sets (2)

phone

number

name

Organization

Gives

Award

name

year

Does this solve the problem?


Weak entity sets 3 l.jpg
Weak Entity Sets (3)

  • Weak entity sets are entity sets that are not uniquely identified by their attributes

  • A weak entity set has an "identifying relationship“ (תלות זיהוי) with an entity set that is the "identifying owner“ (הבעלים המזהה) of the weak entity set


Weak entity sets 4 l.jpg
Weak Entity Sets (4)

A weak entity set must:

  • participate fully in the identifying relationship ( a thick line)

  • participate in a one to many relationship with the identifying owner (an arrow)

     Weak entity sets have a thick rectangle, their keys are underlined with a broken line, and the identifying relationship has a thick diamond


Weak entity sets 5 l.jpg
Weak Entity Sets (5)

phone

number

name

Organization

Gives

Award

name

year


Example38 l.jpg
Example

author

id

title

Book

isbn

Person

Copy Of

Borrowed

Copy

copy number

condition


What if we store information about many libraries l.jpg
What if We Store Information About Many Libraries?

Owned By

name

Library

author

Book

title

id

isbn

Person

Copy Of

Borrowed

Copy

copy number

condition


Isa hierarchies l.jpg
ISA Hierarchies

ISA Relationships: Define a hierarchy between entity sets

  • ISA is similar to inheritance

     ISA relationships are drawn as a triangle with the word ISA inside it. The "super entity-set" is above the triangle and the "sub entity-sets" are below


Example41 l.jpg
Example

  • What are the keys of:

  • Movie Person

  • Actor

  • Director

address

id

birthday

Movie Person

name

ISA

picture

Director

Actor


Overlap constraints l.jpg
Overlap Constraints

  • Overlap constraints: Determine whether two sub-entity sets can contain the same entity

    • Example: Can an Actor be a Director?

       Write "Actor OVERLAPS Director". If not written, assume no overlap


Covering constraints l.jpg
Covering Constraints

  • Covering constraints: Determine whether every entity in the super-entity set is also in at least one of the sub-entity sets

    • Example: Is every movie person either an Actor or a Director?

       Write "Actor AND Director COVER Movie Person". If not written, assume no covering


Example44 l.jpg
Example

parent

woman

man

child

ParentOf

Married

Person

name

id

Is this good?

A man can be married to a man and a woman to a woman!


Example45 l.jpg
Example

parent

name

ParentOf

child

Person

id

Man AND Woman

COVER Person

ISA

Married

Man

Woman


Aggregation l.jpg
Aggregation

  • Aggregation: Allows us to indicate that a relationship set participates in a relationship set


Is this good 1 l.jpg
Is this good? (1)

picture

Actor

salary

Acted In

Award

year

Movie

title

type

  • Each movie has received at least one award

  • Each actor has received at least one award


Is this good 2 l.jpg
Is this good? (2)

picture

Actor

salary

Acted In

Won

Award

year

Movie

title

type

The same award can be granted to an actor A and to a movie F although the actor A has not acted in the movie F.


Solution use aggregation l.jpg
Solution: Use Aggregation

picture

Actor

Won

salary

Acted In

Award

year

Movie

title

type


Slide50 l.jpg

address

id

birthday

Movie Person

name

phone

number

name

ISA

Organization

Gives

picture

Director

Actor

Won

salary

Acted In

Directed

Award

year

name

Movie

year

title

type


ad
  • Login