Vous êtes sur la page 1sur 2

create database shop_assingment ; use shop_assingment; /*student id = k00133387 , name=layth darraji*/ /*1.

Write an SQL statement to Create the Customer Table as described below:*/ create table customer ( customer_id int constraint pk_customer_id primary key identity , fname varchar(25) not null, lname varchar(35) not null, city varchar(35)default 'limerick' check (city in ('limerick','cork','galway','waterford','dublin') ), age int default 18 ); /*2. Write an SQL statement to Create the Supplier Table as described below*/ create table supplier ( supplier_id int constraint pk_supplier_id primary key identity , sname varchar(25) not null, lname varchar(35) not null, city varchar(35) default 'limerick', check (city in ('limerick','cork','galway','waterford','dublin') ), ); /*3. Write an SQL statement to Create the Products Table as described below:*/ create table products ( product_id int constraint pk_product_id primary key identity , pname varchar(25) not null , supplier_id int constraint fk_supplier_id foreign key(supplier_i d) references supplier(supplier_id), price decimal(6,2) default 1.00, ); /*4. Write an SQL statement to Create the Orders Table as described below:*/ create table orders ( order_id int constraint pk_order_id primary key identity, customer_id int constraint fk_customer_id foreign key(customer_i d) references customer(customer_id), date_of_order smalldatetime default getdate(), delivery_of_order smalldatetime default getdate()+3, ); /*5. Write an SQL statement to Create the OrdersDetailsTable as described below: */ create table orders_details ( order_detail_id int, order_id int constraint fk_order_id foreign key(order_id) refere nces orders(order_id), product_id int constraint fk_product_id foreign key(product_id) references products(product_id), Qty int default 1, discount decimal (3,2) null , );

Vous aimerez peut-être aussi