22
Dr./ Ahmed Mohamed Rabie 1

Dr./ Ahmed Mohamed Rabiestaff.du.edu.eg/upfilestaff/1058/101058_a1574422322__.pdf · Dr./ Ahmed Mohamed Rabie 1. 2 Text Book. 3. 4 Example 1:-The University database stores details

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Dr./ Ahmed Mohamed Rabiestaff.du.edu.eg/upfilestaff/1058/101058_a1574422322__.pdf · Dr./ Ahmed Mohamed Rabie 1. 2 Text Book. 3. 4 Example 1:-The University database stores details

Dr./ Ahmed Mohamed Rabie

1

Page 2: Dr./ Ahmed Mohamed Rabiestaff.du.edu.eg/upfilestaff/1058/101058_a1574422322__.pdf · Dr./ Ahmed Mohamed Rabie 1. 2 Text Book. 3. 4 Example 1:-The University database stores details

2

Text Book

Page 3: Dr./ Ahmed Mohamed Rabiestaff.du.edu.eg/upfilestaff/1058/101058_a1574422322__.pdf · Dr./ Ahmed Mohamed Rabie 1. 2 Text Book. 3. 4 Example 1:-The University database stores details

3

Page 4: Dr./ Ahmed Mohamed Rabiestaff.du.edu.eg/upfilestaff/1058/101058_a1574422322__.pdf · Dr./ Ahmed Mohamed Rabie 1. 2 Text Book. 3. 4 Example 1:-The University database stores details

4

Example 1:- The University database stores details

about university students, courses, the semester a

student took a particular course (and his mark and

grade if he completed it), and what degree program

each student is enrolled in . The database is a long

way from one that’d be suitable for a large institution.

• The university offers one or more programs.

• A program is made up of one or more courses.

• A student must enroll in a program.

Page 5: Dr./ Ahmed Mohamed Rabiestaff.du.edu.eg/upfilestaff/1058/101058_a1574422322__.pdf · Dr./ Ahmed Mohamed Rabie 1. 2 Text Book. 3. 4 Example 1:-The University database stores details

5

• A student takes the courses that are part of this

program.

• A program has a name, a program identifier, the total

credit points required to graduate, and the year it

commenced.

• A course has a name, a course identifier, a credit

point value, and the year it commenced.

• Students have one or more given names, a surname, a

student identifier, a date of birth, and the year they

first enrolled .

Page 6: Dr./ Ahmed Mohamed Rabiestaff.du.edu.eg/upfilestaff/1058/101058_a1574422322__.pdf · Dr./ Ahmed Mohamed Rabie 1. 2 Text Book. 3. 4 Example 1:-The University database stores details

6

• When a student takes a course, the year and

semester he attempted it are recorded . When he

finishes the course, a grade (such as A or B) and a

mark (such as 60 percent) are recorded.

• Each course in a program is sequenced into a year

(for example, year 1 )and a semester (for example

‘(semester 1).

Design ER schema for University database.

Page 7: Dr./ Ahmed Mohamed Rabiestaff.du.edu.eg/upfilestaff/1058/101058_a1574422322__.pdf · Dr./ Ahmed Mohamed Rabie 1. 2 Text Book. 3. 4 Example 1:-The University database stores details

7

Page 8: Dr./ Ahmed Mohamed Rabiestaff.du.edu.eg/upfilestaff/1058/101058_a1574422322__.pdf · Dr./ Ahmed Mohamed Rabie 1. 2 Text Book. 3. 4 Example 1:-The University database stores details

8

Example 2: The Flight database stores details about an

airline’s fleet, flights, and seat bookings. Again, it’s a

hugely simplified version of what a real airline would

use ،but the principles are the same .

• The airline has one or more airplanes.

• An airplane has a model number, a unique

registration number, and the capacity to take one or

more passengers.

Page 9: Dr./ Ahmed Mohamed Rabiestaff.du.edu.eg/upfilestaff/1058/101058_a1574422322__.pdf · Dr./ Ahmed Mohamed Rabie 1. 2 Text Book. 3. 4 Example 1:-The University database stores details

9

• An airplane flight has a unique flight number, a

departure airport, a destination airport, a departure

date and time, and an arrival date and time.

• Each flight is carried out by a single airplane.

• A passenger has given names, a surname, and a

unique email address.

• A passenger can book a seat on a flight.

Design ER schema for Flight database.

Page 10: Dr./ Ahmed Mohamed Rabiestaff.du.edu.eg/upfilestaff/1058/101058_a1574422322__.pdf · Dr./ Ahmed Mohamed Rabie 1. 2 Text Book. 3. 4 Example 1:-The University database stores details

10

Page 11: Dr./ Ahmed Mohamed Rabiestaff.du.edu.eg/upfilestaff/1058/101058_a1574422322__.pdf · Dr./ Ahmed Mohamed Rabie 1. 2 Text Book. 3. 4 Example 1:-The University database stores details

11

Example 3:- Design a database to keep track of

information for an Art museum. Assume that the

following requirements were collected:

The museum has a collection of art objects. Each art

object has a unique identification, an artist (if

known), a year (when it was created, if known), a

title, an epoch (Renaissance, Modern, Ancient, etc.),

and a description. The arts objects are classified in

the museum in several ways as discussed below:

Page 12: Dr./ Ahmed Mohamed Rabiestaff.du.edu.eg/upfilestaff/1058/101058_a1574422322__.pdf · Dr./ Ahmed Mohamed Rabie 1. 2 Text Book. 3. 4 Example 1:-The University database stores details

12

Arts objects are categorized based on their type.

The main types are: painting and sculpture, plus

another type they called “other” to accommodate

objects that do not fall into one of the two main

types.

A painting has a paint type (oil, watercolor, etc.),

material on which it is draw on (paper, canvas,

wood, etc.), and style (modern, abstract,

impressionism, etc.).

Page 13: Dr./ Ahmed Mohamed Rabiestaff.du.edu.eg/upfilestaff/1058/101058_a1574422322__.pdf · Dr./ Ahmed Mohamed Rabie 1. 2 Text Book. 3. 4 Example 1:-The University database stores details

13

A sculpture has a material from which it was

created (wood, stone, iron, etc.), height, weight,

and style.

An art object in the other category has a type

(print, photo, etc.) and a style.

Art objects are also categorized as permanent

collection that are owned by the museum (which

has information on the date acquired, whether it is

on display or stored, and cost) or borrowed, which

has information on the collection (from which it

was borrowed) date borrowed, and date returned.

Page 14: Dr./ Ahmed Mohamed Rabiestaff.du.edu.eg/upfilestaff/1058/101058_a1574422322__.pdf · Dr./ Ahmed Mohamed Rabie 1. 2 Text Book. 3. 4 Example 1:-The University database stores details

14

The museum keeps track of artist’s information, if

known: name, date of birth, date of death (if not

living), country of birth, epoch, main style,

description. The name is assumed to be unique.

Different exhibitions occur, each having a name, a

start date, an end date, and are related to all the art

objects that were on display during the exhibition.

Information is kept on other collections with which

the museum interacts, including name (unique),

type (museum, personal, etc.), description, address,

phone, and current contact person. Design EER

schema for Art museum

Page 15: Dr./ Ahmed Mohamed Rabiestaff.du.edu.eg/upfilestaff/1058/101058_a1574422322__.pdf · Dr./ Ahmed Mohamed Rabie 1. 2 Text Book. 3. 4 Example 1:-The University database stores details

15

Page 16: Dr./ Ahmed Mohamed Rabiestaff.du.edu.eg/upfilestaff/1058/101058_a1574422322__.pdf · Dr./ Ahmed Mohamed Rabie 1. 2 Text Book. 3. 4 Example 1:-The University database stores details

16

Page 17: Dr./ Ahmed Mohamed Rabiestaff.du.edu.eg/upfilestaff/1058/101058_a1574422322__.pdf · Dr./ Ahmed Mohamed Rabie 1. 2 Text Book. 3. 4 Example 1:-The University database stores details

17

Exercise:- The Music Database, the music database

stores details of a personal music library, and could

be used to manage your MP3 ،CD, or vinyl

collection. Because this database is for a personal

collection, it’s relatively simple and stores only the

relationships between artists, albums, and tracks. It

ignores the requirements of many music genres,

making it most useful for storing popular music and

less useful for storing jazz or classical music.

Page 18: Dr./ Ahmed Mohamed Rabiestaff.du.edu.eg/upfilestaff/1058/101058_a1574422322__.pdf · Dr./ Ahmed Mohamed Rabie 1. 2 Text Book. 3. 4 Example 1:-The University database stores details

18

• The collection consists of albums.

• An album is made by exactly one artist.

• An artist makes one or more albums.

• An album contains one or more tracks

• Artists, albums, and tracks each have a name.

• Each track is on exactly one album.

• Each track has a time length, measured in seconds.

• When a track is played, the date and time the

playback began (to the nearest second) should be

recorded; this is used for reporting when a track

was last played, as well as the number of times

music by an artist, from an album, or a track has

been played.

Page 19: Dr./ Ahmed Mohamed Rabiestaff.du.edu.eg/upfilestaff/1058/101058_a1574422322__.pdf · Dr./ Ahmed Mohamed Rabie 1. 2 Text Book. 3. 4 Example 1:-The University database stores details

19

Exercise:- Design an ER schema for keeping track

of information about votes taken in the U.S. House of

Representatives during the current two-year

congressional session. The database needs to keep

track of each U.S. STATE’s Name(e.g., ‘Texas’, ‘New

York’, ‘California’) and include the Region of the

state (whose domain is {‘Northeast’, ‘Midwest’,

‘Southeast’, ‘Southwest’, ‘West’}). Each

CONGRESS_PERSON in the House of

Representatives is described by his or her Name, plus

the District represented, the Start_date when the

congressperson was first elected, and the political

Page 20: Dr./ Ahmed Mohamed Rabiestaff.du.edu.eg/upfilestaff/1058/101058_a1574422322__.pdf · Dr./ Ahmed Mohamed Rabie 1. 2 Text Book. 3. 4 Example 1:-The University database stores details

20

Party to which he or she belongs (whose domain is

{‘Republican’, ‘Democrat’,‘Independent’, ‘Other’}).

The database keeps track of each BILL (i.e., proposed

law), including the Bill_name, the Date_of_vote on

the bill, whether the bill Passed_or_failed (whose

domain is {‘Yes’, ‘No’}), and the Sponsor (the

congressperson(s) who sponsored—that is,

proposed—the bill). The database also keeps track of

how each congressperson voted on each bill (domain

of Vote attribute is {‘Yes’, ‘No’, ‘Abstain’, ‘Absent’}).

Draw an ER schema diagram for this application.

State clearly any assumptions you make.

Page 21: Dr./ Ahmed Mohamed Rabiestaff.du.edu.eg/upfilestaff/1058/101058_a1574422322__.pdf · Dr./ Ahmed Mohamed Rabie 1. 2 Text Book. 3. 4 Example 1:-The University database stores details

21

Exercise:- The following narrative describes a

simplified version of the organization of Olympic

facilities planned for the summer Olympics. Draw an

EER diagram that shows the entity types, attributes,

relationships, and specializations for this application.

State any assumptions you make. The Olympic

facilities are divided into sports complexes. Sports

complexes are divided into one-sport and multisport

types. Multisport complexes have areas of the

complex designated for each sport with a location

indicator (e.g., center, NE corner, and so on.

Page 22: Dr./ Ahmed Mohamed Rabiestaff.du.edu.eg/upfilestaff/1058/101058_a1574422322__.pdf · Dr./ Ahmed Mohamed Rabie 1. 2 Text Book. 3. 4 Example 1:-The University database stores details

22

A complex has a location, chief organizing individual, total

occupied area, and so on. Each complex holds a series of

events (e.g., the track stadium may hold many different

races). For each event there is a planned date, duration,

number of participants, number of officials, and so on. A

roster of all officials will be maintained together with the

list of events each official will be involved in. Different

equipment is needed for the events (e.g., goal posts, poles,

parallel bars) as well as for maintenance. The two types of

facilities (one-sport and multisport) will have different

types of information. For each type, the number of

facilities needed is kept, together with an approximate

budget.