SCHOOL OF COMMERCE DEPARTMENT OF BAIS SECTION 2 DATABASE II ASSIGNMENT Prepared By ID No 1. Towfik Sefa ………………………………….………..UGR/9940/12 2. Nahom Abera………………………………………….UGR/3278/12 3.Tigest Kefelegn…………………..…………………… UGR/3256/12 Submitted to: Dr Tillahun Submission Date: Tuesday, April 5, 2022 Exercise Conduct Database Datamodel create database DVD_Rental; use DVD_Rental; --to create a category table create table category( category_id varchar(50) not null primary key, [name] nvarchar (50) not null, last_update date ); select * from category; --to create a film_catagore table create table film_categore( film_id varchar(50) not null, category_id varchar(50) not null, last_update date, constraint PK_film_category primary key(film_id, category_id) ); select * from film_categore; --to create a film table create table film( film_id varchar(50) not null primary key, title nvarchar(50) not null, [description] nvarchar(255), release_year date, language_id varchar(30) not null, rental_duration varchar(50) not null, [length] time, replacement_cost smallmoney not null, rating varchar not null, last_update date, special_features varchar(255), [fulltext] varchar(4000), constraint UC_film unique(title, [description]) ); select * from film; --to create a language table create table [language]( language_id varchar(30) not null primary key, [name] nvarchar not null, last_update date ); select * from language; --to create film_actor table create table film_actor( actor_id varchar(50) not null, film_id varchar(50) not null, last_update date, constraint PK_film_actor primary key(actor_id, film_id) ); select * from film_actor; --to create an inventory table create table inventory( inventory_id varchar(50) not null, [name] nvarchar(50) not null, last_update date primary key(inventory_id) ); select * from inventory; --to creat a rental table create table rental( rental_id varchar(50) not null, rental_date date not null, inventory_id varchar(50) not null, customer_id varchar(50) not null, return_date date not null, staff_id varchar not null, last_update date, primary key(rental_id), constraint UC_rental unique(rental_id, rental_date, inventory_id, customer_id, staff_id) ); select * from rental; --to create a payment table create table payment( payment_id varchar(50) not null primary key, customer_id varchar(50) not null unique, staff_id varchar(50) not null unique, rental_id varchar(50) not null unique, amount smallmoney not null, payment_date date not null, constraint UC_payment unique(payment_id, customer_id, staff_id, rental_id) ); select * from film_actor; --to create a staff create table staff( staff_id varchar(50) not null primary key, first_name nvarchar(50) not null, last_name nvarchar(50) not null, address_id varchar(50) not null, email varchar(50), store_id varchar(50) not null, active bit not null, username nvarchar not null, [password] varchar(50), last_update date, picture image not null, constraint UC_staff unique(first_name, last_name, email, username, [password]) ); select * from staff; --to create an actor table create table actor( actor_id varchar(50) not null, first_name nvarchar(50) not null, last_name nvarchar(50) not null, last_update date, constraint PK_actor primary key(actor_id), constraint UC_actor unique(first_name, last_name) ); select * from actor; --to create a customer table create table customer( customer_id varchar(50) not null primary key, store_id varchar(50) not null, first_name nvarchar(50) not null, last_name nvarchar(50) not null, email varchar(50) not null, address_id varchar(50) not null, activebool bit not null, create_date date, last_update date, active bit not null, constraint UC_customet unique(customer_id, store_id, email, address_id, first_name, last_name) ); select * from customer; --to create an address table create table address( address_id varchar(50) not null, [address] nvarchar(50) not null, address2 nvarchar(50), district nvarchar(50), city_id varchar(50) not null, postal_code varchar(50), phone varchar(20) not null, last_update date, primary key(address_id), constraint UK_address unique(address_id, phone, postal_code, [address]) ); select * from address; --to create a city table create table city( city_id varchar(50) not null primary key, city nvarchar(50) not null, country_id varchar(50) not null, last_update date, constraint UC_city unique(city_id, country_id) ); select * from city; --to create a country table create table country( country_id varchar(50) not null, country varchar(50) not null, last_update date, constraint PK_country primary key(country_id) ); select * from country; --to create a store table create table store( store_id varchar(50) not null, manager_staff_id varchar(50) not null, address_id varchar(50) not null, last_update date, constraint UC_store unique(store_id, manager_staff_id, address_id) ); select * from store; DB2SQLQuery(ASSIGNMENT) Page | 2