Download ER Diagram for the movie database

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Open Database Connectivity wikipedia , lookup

Clusterpoint wikipedia , lookup

Microsoft SQL Server wikipedia , lookup

Object-relational impedance mismatch wikipedia , lookup

Extensible Storage Engine wikipedia , lookup

SQL wikipedia , lookup

PL/SQL wikipedia , lookup

Database model wikipedia , lookup

Relational model wikipedia , lookup

Null (SQL) wikipedia , lookup

Transcript
ABSTRACT
This document uses Oracle Data Modeler to create a SQL
server database based on a set of users.
Kentraeus Hale
CIS 404
ER MODELING
Movie Database
USERS’ REQUIREMENTS
THE MOVIE DATABASE
“I’m the owner of a small movie rental store. We have over 3,000 movies that we need to keep
track of. Each of our movies has a DVD or VHS tape number. For each movie, we need to know
its title and category (e.g., comedy, suspense, drama, action, war, or sci-fi).
Yes, we do have multiple copies of many of our movies. We give each movie a specific ID, and
then track which DVD or VHS contains the movie. A movie can be either DVD or VHS format.
We always have at least one DVD or VHS tape for each movie we track, and each DVD or VHS
tape is always a copy of a single, specific movie.
Our DVDs and VHS tapes are very long. We don’t have any movies that require multiple DVDs
or VHS tapes."
"We are frequently asked for movies starring specific actors. John Wayne and Julia Roberts are
always popular. So we’d like to keep track of the star actors appearing in each movie. Not all of
our movies have star actors. Customers like to know each actor’s “real” birth name and date of
birth. We track only actors who appear in the movies in our inventory.
We have lots of customers. We rent videos only to people who have joined our 'video club.' To
belong to our club, they must have good credit. For each club member, we’d like to keep their
first and last name, current phone number, and current address. And, of course, each club
member has a membership number.
Then we need to keep track of what video tapes each customer currently has checked out. A
customer may check out multiple video tapes at any given time. We just track current rentals. We
don’t keep track of any rental histories.”
We would like to keep the rental date/time and the return date/time. All our tapes are due back
the next day, so we don’t need to keep a due date. Keeping this rental history will allow us to
analyze the pattern of our rentals. We will be able to determine how many tapes each customer
rents and how many times a customer has returned a tape late. We will also know how many
times a particular tape has been used and will then know when to retire each tape. We will also
be able to analyze our customers’ movie preferences.”
KENTRAEUS HALE
1
Analysis of User’ Requirements
List of entities and their Attributes
Movies
1. Movie ID
2. Title
3. Category
Customers
1. Membership ID
2. Last Name
3. First Name
4. Phone Number
5. Address
6. Credit
Copies
1. Copy ID
2. Type
Rental
1. Rental ID
2. Issue Date
3. Return Date
Actor
1. Actor ID
2. Birth Name
3. Actor Name
4. DOB
KENTRAEUS HALE
2
ER Diagram
Customers
1
Makes
N
Rental
M
HAS
N
BEGUN
N
Copies
1
Movies
KENTRAEUS HALE
N
APPEAL
M
Actors
3
This ER Diagram will in 7 tables
1. 5 tables one for every entities
2. 2 tables for the two many to many relationship
KENTRAEUS HALE
4
The Relational Model in Data Modeler
KENTRAEUS HALE
5
DDL for SQL Server 2008
-- Generated by Oracle SQL Developer Data Modeler 4.0.2.840
-- at:
2015-3-11 10:27:05 CDT
-- site: SQL Server 2008
-- type: SQL Server 2008
CREATE
TABLE Actor
(
ActorID INTEGER NOT NULL ,
BirthName VARCHAR (25) NOT NULL ,
ScreenName VARCHAR (25) NOT NULL ,
DOB
DATETIME NOT NULL ,
CONSTRAINT Actor_PK PRIMARY KEY CLUSTERED (ActorID)
WITH
(
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON
)
ON "default"
)
ON "default"
GO
CREATE
TABLE Appeal
(
Movies_MoviesID INTEGER NOT NULL ,
Actor_ActorID INTEGER NOT NULL ,
CONSTRAINT Appeal__IDX PRIMARY KEY CLUSTERED (Movies_MoviesID,
Actor_ActorID)
WITH
(
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON
)
ON "default"
)
ON "default"
GO
CREATE
KENTRAEUS HALE
6
TABLE Copies
(
CopyID
INTEGER NOT NULL ,
Tye
CHAR (1) NOT NULL ,
Movies_MoviesID INTEGER NOT NULL ,
CONSTRAINT Copies_PK PRIMARY KEY CLUSTERED (CopyID)
WITH
(
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON
)
ON "default"
)
ON "default"
GO
CREATE
TABLE Customer
(
MembershipID INTEGER NOT NULL ,
LastName VARCHAR (25) NOT NULL ,
FirstName VARCHAR (25) NOT NULL ,
Address VARCHAR (50) NOT NULL ,
Phone
CHAR (10) NOT NULL ,
Credit
VARCHAR (10) NOT NULL ,
CONSTRAINT Customer_PK PRIMARY KEY CLUSTERED (MembershipID)
WITH
(
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON
)
ON "default"
)
ON "default"
GO
CREATE
TABLE HAS
(
Rental_RentalID INTEGER NOT NULL ,
Copies_CopyID INTEGER NOT NULL ,
CONSTRAINT HAS__IDX PRIMARY KEY CLUSTERED (Rental_RentalID, Copies_CopyID)
WITH
(
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON
)
KENTRAEUS HALE
7
ON "default"
)
ON "default"
GO
CREATE
TABLE Movies
(
MoviesID INTEGER NOT NULL ,
Title VARCHAR (25) NOT NULL ,
Category VARCHAR (15) NOT NULL ,
CONSTRAINT Movies_PK PRIMARY KEY CLUSTERED (MoviesID)
WITH
(
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON
)
ON "default"
)
ON "default"
GO
CREATE
TABLE Rental
(
RentalID
INTEGER NOT NULL ,
IssueDate
DATETIME NOT NULL ,
ReturnDate
DATETIME ,
Customer_MembershipID INTEGER NOT NULL ,
CONSTRAINT Rental_PK PRIMARY KEY CLUSTERED (RentalID)
WITH
(
ALLOW_PAGE_LOCKS = ON ,
ALLOW_ROW_LOCKS = ON
)
ON "default"
)
ON "default"
GO
ALTER TABLE Copies
ADD CONSTRAINT Copies_Movies_FK FOREIGN KEY
(
Movies_MoviesID
)
REFERENCES Movies
(
KENTRAEUS HALE
8
MoviesID
)
ON
DELETE
NO ACTION ON
UPDATE NO ACTION
GO
ALTER TABLE Appeal
ADD CONSTRAINT FK_ASS_1 FOREIGN KEY
(
Movies_MoviesID
)
REFERENCES Movies
(
MoviesID
)
ON
DELETE
NO ACTION ON
UPDATE NO ACTION
GO
ALTER TABLE Appeal
ADD CONSTRAINT FK_ASS_2 FOREIGN KEY
(
Actor_ActorID
)
REFERENCES Actor
(
ActorID
)
ON
DELETE
NO ACTION ON
UPDATE NO ACTION
GO
ALTER TABLE HAS
ADD CONSTRAINT FK_ASS_4 FOREIGN KEY
(
Rental_RentalID
)
REFERENCES Rental
(
RentalID
)
KENTRAEUS HALE
9
ON
DELETE
NO ACTION ON
UPDATE NO ACTION
GO
ALTER TABLE HAS
ADD CONSTRAINT FK_ASS_5 FOREIGN KEY
(
Copies_CopyID
)
REFERENCES Copies
(
CopyID
)
ON
DELETE
NO ACTION ON
UPDATE NO ACTION
GO
ALTER TABLE Rental
ADD CONSTRAINT Rental_Customer_FK FOREIGN KEY
(
Customer_MembershipID
)
REFERENCES Customer
(
MembershipID
)
ON
DELETE
NO ACTION ON
UPDATE NO ACTION
GO
-- Oracle SQL Developer Data Modeler Summary Report:
--- CREATE TABLE
7
-- CREATE INDEX
0
-- ALTER TABLE
6
-- CREATE VIEW
0
-- CREATE PACKAGE
0
-- CREATE PACKAGE BODY
0
-- CREATE PROCEDURE
0
-- CREATE FUNCTION
0
KENTRAEUS HALE
10
-- CREATE TRIGGER
0
-- ALTER TRIGGER
0
-- CREATE DATABASE
0
-- CREATE DEFAULT
0
-- CREATE INDEX ON VIEW
0
-- CREATE ROLLBACK SEGMENT
0
-- CREATE ROLE
0
-- CREATE RULE
0
-- CREATE PARTITION FUNCTION
0
-- CREATE PARTITION SCHEME
0
--- DROP DATABASE
0
--- ERRORS
0
-- WARNINGS
0
KENTRAEUS HALE
11
Database in SQL Server
KENTRAEUS HALE
12