Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

This is the given sql /* Delete the tables if they already exist */ drop table if exists Movie; drop table if exists Reviewer; drop

This is the given sql

/* Delete the tables if they already exist */ drop table if exists Movie; drop table if exists Reviewer; drop table if exists Rating;

/* Create the schema for our tables */ create table Movie(mID int, title VARCHAR(200), year int, director VARCHAR(200)); create table Reviewer(rID int , name VARCHAR(200) ); create table Rating(rID int, mID int, stars int , ratingDate date);

/* Populate the tables with our data */ insert into Movie values(101, 'Gone with the Wind', 1939, 'Victor Fleming'); insert into Movie values(102, 'Star Wars', 1977, 'George Lucas'); insert into Movie values(103, 'The Sound of Music', 1965, 'Robert Wise'); insert into Movie values(104, 'E.T.', 1982, 'Steven Spielberg'); insert into Movie values(105, 'Titanic', 1997, 'James Cameron'); insert into Movie values(106, 'Snow White', 1937, null); insert into Movie values(107, 'Avatar', 2009, 'James Cameron'); insert into Movie values(108, 'Raiders of the Lost Ark', 1981, 'Steven Spielberg');

insert into Reviewer values(201, 'Sarah Martinez'); insert into Reviewer values(202, 'Daniel Lewis'); insert into Reviewer values(203, 'Brittany Harris'); insert into Reviewer values(204, 'Mike Anderson'); insert into Reviewer values(205, 'Chris Jackson'); insert into Reviewer values(206, 'Elizabeth Thomas'); insert into Reviewer values(207, 'James Cameron'); insert into Reviewer values(208, 'Ashley White');

insert into Rating values(201, 101, 2, '2011-01-22'); insert into Rating values(201, 101, 4, '2011-01-27'); insert into Rating values(202, 106, 4, null); insert into Rating values(203, 103, 2, '2011-01-20'); insert into Rating values(203, 108, 4, '2011-01-12'); insert into Rating values(203, 108, 2, '2011-01-30'); insert into Rating values(204, 101, 3, '2011-01-09'); insert into Rating values(205, 103, 3, '2011-01-27'); insert into Rating values(205, 104, 2, '2011-01-22'); insert into Rating values(205, 108, 4, null); insert into Rating values(206, 107, 3, '2011-01-15'); insert into Rating values(206, 106, 5, '2011-01-19'); insert into Rating values(207, 107, 5, '2011-01-20'); insert into Rating values(208, 104, 3, '2011-01-02');

image text in transcribed

I need help with the syntax And also what key am I suppose to use? unique? primary? foreign? pls explain.

Schema: Movie (mID, title, year, director) English: There is a movie with ID number mie, a title, a release year, and a director Reviewer (R, name) English: The reviewer with ID number dR has a certain name. Rating LrD mID, stars, ratingDate) English: The reviewer R gave the movie mlD a.number.of stars rating (1-5) on a certain ratingRate. Unlike most of our other exercises, which are a set of queries to be written individually, this exercise set involves bigger chunks of work followed by a series of tests. If the constraints are implemented correctly, the tests will generate or not generate errors as specified. To verify that the referential integrity policies are implemented correctly, there is a check of the final database state. Task 1: Constraint Declarations Modify the three CREATE TABLE statements in the ratingJlab.sal to add the following constraints. Your three resulting CREATE TABLE statements should meet both the Key constraints and Non-Null constraints Key Constraints 1. mD is a key for Movie and (titleyeac) is another key for Movie 2. uD is a key for Reviewer 3. (R.mUR.tatingDate) is a key for Rating but with null values allowed Non-Null Constraints 4. Reviewer.name may not be NULL 5. Rating.stars, may not be NULL

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Basics Computer EngineeringInformation Warehouse Basics From Science

Authors: Odiljon Jakbarov ,Anvarkhan Majidov

1st Edition

620675183X, 978-6206751830

More Books

Students explore these related Databases questions

Question

Define Administration and Management

Answered: 3 weeks ago

Question

Define organisational structure

Answered: 3 weeks ago

Question

Define line and staff authority

Answered: 3 weeks ago

Question

Define the process of communication

Answered: 3 weeks ago