Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Debugging the following? CREATE TABLE genres ( name text UNIQUE position integer

ID: 3602974 • Letter: D

Question

 Debugging the following?   CREATE TABLE genres (         name text UNIQUE         position integer ) CREATE TABLE movies (         movie_id SERIAL PRIMARY KEY,         title text,         genre cube ; CREATE TABLE actors (         actor_id SERIAL PRIMARY KEY,         name text );  CREATE TABLE movies_actors (         movie_id integer REFERENCES movies NULL,         actor_id integer REFERENCES actors NOT NULL,         UNIQUE (movie_id, actor_id) ); CREATE INDEX movies_actors_movie_id ON movies_actors (movie_id) CREATE INDEX movies_actors_actor_id ON movies_actors (actor_id); CREATE INDEX movies_genres_cube ON movies USING gist (genre); 

Explanation / Answer

CREATE TABLE genres (
name varchar(255) UNIQUE,
position int
);

CORRECTIONS IN THIS QUERY:

1. text is not a data type, varchar is one for text type data.

2.Comma is missing after second line.

3.Semicolon is missing at the end.

-------------------------------------------------------

CREATE TABLE movies (
movie_id SERIAL PRIMARY KEY,
title varchar(255),
genre cube
);

CORRECTIONS IN THIS QUERY:

1.Again varchar should be there instead of text as data type.

2.Brace at the end, before semocolon is missing.

------------------------------------------------------------------------------------

CREATE TABLE actors (
actor_id SERIAL PRIMARY KEY,
name varchar(255)
);

CORRECTIONS IN THIS QUERY:

1.Again varchar should be there instead of text as data type.

------------------------------------------------------------------------------------

CORRECTIONS IN THIS QUERY:

No changes required in this query , it's working well.

----------------------------------------------------------------------------

CREATE INDEX movies_actors_movie_id ON movies_actors (movie_id);

CORRECTIONS IN THIS QUERY:

1. semicolon is missing at the end.

-----------------------------------------------------------------------------------------------------

CREATE INDEX movies_actors_actor_id ON movies_actors (actor_id);

CORRECTIONS IN THIS QUERY:

No changes required in this query , it's working well.

------------------------------------------------------------------------------------------------------

CREATE INDEX movies_genres_cube ON movies (genre);

CORRECTIONS IN THIS QUERY:

1.This query is working well without " USING gist" and I am not able to explain what actually this "gist" is beacuse you haven't mentioned that what you are supposed to do in this query.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote