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.




1. The first law of thermodynamics and the conservation of energy, as discussed in Conservation of Energy, are clearly related. How do they differ in the types of energy considered? 2. Heat transfer QQ and work done WW are always energy in transit, whereas internal energy UU is energy stored in a system. Give an example of each type of energy, and state specifically how it is either in transit or resides in a system. 3. How do heat transfer and internal energy differ? In particular, which can be stored as such in a system and which cannot?a) A stationary closed system goes through a process from state 1 to state 2 and returns from state 2 to state 1 as shown in Figure Q1a. Write the First Law of Thermodynamics or energy balance equation for the system as it goes through process 1-2. ii. The change in internal energy for process 1-#2 is 60 J. The work done on the system for the return process 2-#1 is 30 J. What is the amount of heat transferred for this return process 2- 1? Is heat released from the system or is heat received by the system during the return process 2-1? P (Pressure) 1 V (Volume) Figure Q1a3. Suppose that A is a symmetric n xn matrix with eigenvalues A1 2 . . . 2 An. The associated orthonormal eigenvectors are vi, i = 1, ..., n. (a) Show that the spectral decomposition A = VAV can also be written as n A = > i=1 (b) Use the spectral decomposition to show that a Ar 0 for all i = 1, ..., n. (d) Assume that A is positive definite. Show that || Axl|
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
