1819.exam SQL - Jan28 Solved
1819.exam SQL - Jan28 Solved
I. Write the Transact SQL code necessary for creating the following table, named Customers, of a database of a
live streaming platform: (35 points)
(Escribe el código necesario en Transact SQL para crear la siguiente tabla, llamada Customers, en la base de datos de una
plataforma de video en streaming. (35 puntos))
First_name String of maximum length 50. This value must be necessarily ‘Cora’, ‘Iria’, ‘Manuel’, ‘John’, …
provided and (First_name, Last_name) has to be unique.
Last_name String of maximum length 60. This value must be necessarily ‘Romanov’, ‘Smith’, ‘Pérez’, ‘Wardlaw’, …
provided and (First_name, Last_name) has to be unique.
DNI String of fixed length of 9 characters. This value is the primary ‘00000000X’, ‘12345678P’, ‘98989898M’,
key. The value cannot be null and must have 8 numbers followed ‘71382938A’, …
by a letter
LastVideoWatched Integer. The value can be null. It is a foreign key of the table 1, 20103, 50000, 203, …
“Videos” referencing its column VideoID.
DateLastVideo Date. The value must be entered and the default value is the current 12/05/2013, 07/02/2011, 01/01/2001, 11/11/2001
date. …
Address String of max length 100. This value can be null. ‘C/ Ordoño II, 99, León (Spain)’, …
PrefPlatform String of maximum length 15. The value cannot be null. It must ‘PC’, ‘Tablet’, ‘Other’, …
have one of the following values: ‘PC’, ‘Mac’, ‘Tablet’,
‘Smartphone’, ‘Console’, ‘Other’.
II. This question relates to the Northwind database (See over for its E-R diagram). Write an SQL query to show the
all the product IDs and product names bought by the customer whose identifier is ‘LAZYK’. Show also (in the
same query) the name of such customer. (35 points).
NOTE: The name of the customer is stored in the column ‘ContactName’ of the table ‘Customers’
(Esta pregunta está relacionada con la base de datos Northwind (Mirad el diagrama E-R). Escribid una consulta SQL para
mostrar todos los IDs de los productos y los nombres de los productos comprados por el comprador con identificador
‘LAZYK’. Mostrad también el nombre de dicho comprador, en la misma consulta. (35 puntos))
NOTA: El nombre del comprador está almacenado en la columna ‘ContactName’ de la tabla ‘Customers’
III. This question relates to the Northwind database (See its E-R diagram). Write a stored procedure named
avgUnitsInStock that returns the average number of Units in Stock of the products whose category ID is
supplied as input parameter if the input parameter is not null. Write also the SQL sentence that invokes the
stored procedure and passes it the actual input parameter 3 (30 points).
(Esta pregunta está relacionada con la base de datos Northwind (Mirad el diagrama E-R). Escribid un procedimiento
almacenado llamado avgUnitsInStock que devuelve el número medio de unidades en stock de los productos cuyo ID de
1
Solutions Exam SQL 2nd Call (January 28, 2019)