drop table customers;
drop table sales;
drop table orders;
drop table order_lines;


CREATE TABLE customers
 (
    customer_id   NUMBER(5) constraint pk_customer primary key,
    customer_name VARCHAR2(40)
 );

CREATE TABLE sales
 (
    sales_id      NUMBER(5) constraint pk_sales primary key,
    customer_id   NUMBER(5) constraint fk_sales_customer references customers(
    customer_id),
    quantity_sold NUMBER(4)
 );

CREATE TABLE orders
 (
    order_id    NUMBER(5) constraint pk_orders primary key,
    customer_id NUMBER(5) constraint fk_orders_customer references customers(
    customer_id),
    order_value NUMBER(4)
 );


CREATE TABLE order_lines
 (
    orderline_id   NUMBER(5) constraint pk_orderlines primary key,
    order_id       NUMBER(5) constraint fk_orderlines_orders references orders(
    order_id),
    order_quantity NUMBER(4)
 );


INSERT INTO customers
           (customer_id,customer_name)
VALUES      (1,'De Vere');

INSERT INTO customers
           (customer_id,customer_name)
VALUES      (2,'Carrington');

INSERT INTO customers
           (customer_id,customer_name)
VALUES      (3,'Sivert');

INSERT INTO sales
           (sales_id,customer_id,quantity_sold)
VALUES      (1,1,10);

INSERT INTO sales
           (sales_id,customer_id,quantity_sold)
VALUES      (2,1,20);

INSERT INTO sales
           (sales_id,customer_id,quantity_sold)
VALUES      (3,1,30);

INSERT INTO sales
           (sales_id,customer_id,quantity_sold)
VALUES      (4,2,10);

INSERT INTO sales
           (sales_id,customer_id,quantity_sold)
VALUES      (5,2,20);

INSERT INTO orders
           (order_id,customer_id,order_value)
VALUES      (1,1,100);

INSERT INTO orders
           (order_id,customer_id,order_value)
VALUES      (2,1,200);

INSERT INTO orders
           (order_id,customer_id,order_value)
VALUES      (3,1,300);

INSERT INTO orders
           (order_id,customer_id,order_value)
VALUES      (4,2,100);

INSERT INTO orders
           (order_id,customer_id,order_value)
VALUES      (5,2,200);

INSERT INTO orders
           (order_id,customer_id,order_value)
VALUES      (6,3,100);

INSERT INTO orders
           (order_id,customer_id,order_value)
VALUES      (7,3,200);

INSERT INTO order_lines
           (orderline_id,order_id,order_quantity)
VALUES     (1,1,10);

INSERT INTO order_lines
           (orderline_id,order_id,order_quantity)
VALUES     (2,1,20);

INSERT INTO order_lines
           (orderline_id,order_id,order_quantity)
VALUES     (3,2,30);

INSERT INTO order_lines
           (orderline_id,order_id,order_quantity)
VALUES     (4,3,30);

INSERT INTO order_lines
           (orderline_id,order_id,order_quantity)
VALUES     (5,4,10);

INSERT INTO order_lines
           (orderline_id,order_id,order_quantity)
VALUES     (6,4,20);

INSERT INTO order_lines
           (orderline_id,order_id,order_quantity)
VALUES     (7,5,30);

INSERT INTO order_lines
           (orderline_id,order_id,order_quantity)
VALUES     (8,6,10);

INSERT INTO order_lines
           (orderline_id,order_id,order_quantity)
VALUES     (9,6,20);

INSERT INTO order_lines
           (orderline_id,order_id,order_quantity)
VALUES     (10,7,30);

COMMIT;

