Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | Apr 2017 |
Last Sign in: | 9 Weeks Ago, 4 Days Ago |
Questions Answered: | 4870 |
Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
I'm currentley using Oracle 11g.
Â
Study the movie database code in movies.sql so that you know how command file works. In particular, consider the purpose of the StatusValue table.
Try the following, noting what happens and why. Store your DDL/DML commands along with explanations of how/why they work
Â
-- This command file loads a simple movies database, dropping any existingtables-- with the same names, rebuilding the schema and loading the data fresh.---- Drop current databaseDROP TABLE Casting;DROP TABLE Movie;DROP TABLE Performer;-- Create database schemaCREATE TABLE Movie (id integer,title varchar(70) NOT NULL,year decimal(4),score float,votes integer,PRIMARY KEY (id),CHECK (year > 1900));CREATE TABLE Performer (id integer,name varchar(35),PRIMARY KEY (id));CREATE TABLE Casting (movieId integer,performerId integer,status varchar(6),FOREIGN KEY (movieId) REFERENCES Movie(Id) ON DELETE CASCADE,FOREIGN KEY (performerId) REFERENCES Performer(Id) ON DELETE SET NULL,CHECK (status in ('star', 'costar', 'extra')));-- Load sample dataINSERT INTO Movie VALUES (1,'Star Wars',1977,8.9, 2000);INSERT INTO Movie VALUES (2,'Blade Runner',1982,8.6, 1500);INSERT INTO Performer VALUES (1,'Harrison Ford');INSERT INTO Performer VALUES (2,'Rutger Hauer');INSERT INTO Performer VALUES (3,'The Mighty Chewbacca');INSERT INTO Performer VALUES (4,'Rachael');INSERT INTO Casting VALUES (1,1,'star');INSERT INTO Casting VALUES (1,3,'extra');INSERT INTO Casting VALUES (2,1,'star');INSERT INTO Casting VALUES (2,2,'costar');INSERT INTO Casting VALUES (2,4,'costar');
-----------