Question: Question: I'd like to test PostgreSQL code against the following: 1: Insert normal data 2: Insert non-exist foreign key. 3: Insert duplicate rating. 4: Insert
Question:
I'd like to test PostgreSQL code against the following:
1: Insert normal data
2: Insert non-exist foreign key.
3: Insert duplicate rating.
4: Insert a hasagenre record that contains wrong genre id.
5: Insert a rating larger than 5.
** Please Note: The answer will just call for SQL script. SQL script should NOT contain the commands to change the database or set encoding. Please do not use any commands to change Postgres DB settings. All table names and attribute names must be in lowercase letters and match the specification.* *
Here is a description of tables:
users: userid (int, primary key), name (text)
movies: movieid (integer, primary key), title (text)
taginfo: tagid (int, primary key), content (text)
genres: genreid (integer, primary key), name (text)
ratings: userid (int, foreign key), movieid (int, foreign key), rating (numeric), timestamp (bigint, seconds since midnight Coordinated Universal Time (UTC) of January 1, 1970)
tags: userid (int, foreign key), movieid (int, foreign key), tagid (int, foreign key), timestamp (bigint, seconds since midnight Coordinated Universal Time (UTC) of January 1, 1970).
hasagenre: movieid (int, foreign key), genreid (int, foreign key)
Please Note: The requirement only tells you the name and data type of each attribute in each table. Please determine the primary keys, foreign keys, constraints or other necessary settings for the database. The key information in the requirement is just a skeleton and not complete; attributes can be primary keys and foreign keys at the same time.


Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
