You are on page 1of 3

Quiz 2

Question 1

1. Create a new database called “MoviesDB”, and set it to be default db.

create database MOVIESDB

2. Create the next two tables and their relation representation table. (Do not forget the tracking
columns).
a. Movie (id, title, release date).
b. Actor (id, name)

create table movie (


id number(8);
title vaRchar(50);
relasedate varchar(50);

CONSTRAINT PK_ES PRIMARY KEY (id),


FOREIGN KEY (title) ;

);
create table actor (
id number(8);
name varchar(20);

CONSTRAINT PK_ES PRIMARY KEY (id),


FOREIGN KEY (name) ;

);
3. Insert new data in each table, at least 3 rows each.

insert into movie (id , title , relasedate)

values ('888' , 'gaza' ,'2008 ');

insert into movie (id , title , relasedate)

values ('444' , 'gaza', '2007 ');

insert into movie (id , title , relasedate)

values ('245' , 'gaza', '2006 ');

insert into actor (id , name)

values ('1' , 'ahmad' );

insert into actor (id , name)

values ('2' , 'mohamed' );

insert into actor (id , name)

values ('3' , 'yousef' );


4. Create a procedure that takes actor id and returns his/her name.

CREATE PROCEDURE aa (IN id varchar(255),


OUT name )
BEGIN
SELECT * FROM actor where name and id = True ;
SELECT COUNT(*) INTO name FROM actor;
END

Question 2

1- VARCHAR(64000) is an equivalent data type to TEXT.


a. True.
b. False.
2- We can set more than one primary key for one table.
a. True.
b. False
3- In order to make an integer column increase sequentially, we set it to be ________:
a. SEQUENCE
b. TRIGGER
c. AUTO_INCREMENT
4- TINYINT data type is a smaller data type comparing to SMALLINT.
a. True.
b. False.

You might also like