CREATE DATABASE hello_world;

USE hello_world;

CREATE TABLE CUSTOMERS ( 
   ID INT AUTO_INCREMENT, 
   NAME VARCHAR(20) NOT NULL, 
   AGE INT NOT NULL, 
   ADDRESS CHAR (25), 
   SALARY DECIMAL (18, 2), 
   PRIMARY KEY (ID) 
);

INSERT INTO CUSTOMERS VALUES 
(1, 'Ramesh', '32', 'Ahmedabad', 2000), 
(2, 'Khilan', '25', 'Delhi', 1500), 
(3, 'Kaushik', '23', 'Kota', 2500), 
(4, 'Chaitali', '26', 'Mumbai', 6500), 
(5, 'Hardik','27', 'Bhopal', 8500), 
(6, 'Komal', '22', 'MP', 9000), 
(7, 'Muffy', '24', 'Indore', 5500);

UPDATE CUSTOMERS SET NAME = "Nikhil" WHERE ID = 1;

ALTER TABLE CUSTOMERS ADD COLUMN EMAIL varchar(50);

UPDATE CUSTOMERS SET EMAIL = 'ramesh@example.com' WHERE ID = 1; 
UPDATE CUSTOMERS SET EMAIL = 'khilan@example.com' WHERE ID = 2;
UPDATE CUSTOMERS SET EMAIL = 'kaushik@example.com' WHERE ID = 3; 
UPDATE CUSTOMERS SET EMAIL = 'chaitali@example.com' WHERE ID = 4; 
UPDATE CUSTOMERS SET EMAIL = 'hardik@example.com' WHERE ID = 5;
UPDATE CUSTOMERS SET EMAIL = 'komal@example.com' WHERE ID = 6; 
UPDATE CUSTOMERS SET EMAIL = 'muffy@example.com' WHERE ID = 7;

DELETE FROM CUSTOMERS WHERE ID = 3;

TRUNCATE TABLE CUSTOMERS;

DROP TABLE CUSTOMERS;

CREATE VIEW first_view AS SELECT * FROM CUSTOMERS;

CREATE TABLE ORDERS ( 
   ORDER_ID INT AUTO_INCREMENT, 
   CUSTOMER_ID INT, 
   AMOUNT DECIMAL(18, 2), 
   ORDER_DATE DATE, 
   PRIMARY KEY (ORDER_ID), 
   FOREIGN KEY (CUSTOMER_ID) 
   REFERENCES CUSTOMERS(ID) 
);

CREATE VIEW customer_orders_view AS SELECT 
   c.ID AS CustomerID, 
   c.NAME AS CustomerName,
   c.AGE AS CustomerAge, 
   c.ADDRESS AS CustomerAddress, 
   c.SALARY AS CustomerSalary, 
   o.ORDER_ID AS OrderID, 
   o.AMOUNT AS OrderAmount,
   o.ORDER_DATE AS OrderDate 
FROM 
   CUSTOMERS c 
LEFT JOIN 
   ORDERS o ON c.ID = o.CUSTOMER_ID; 
   
   
mysqldump -u root -p hello_world > hello_world_DB

mysql -u root -p hello_world_imported < hello_world_DB


CREATE DATABASE user_management; 

USE user_management; 

CREATE TABLE users ( 
   id INT AUTO_INCREMENT PRIMARY KEY, 
   name VARCHAR(100) NOT NULL, 
   email VARCHAR(100) UNIQUE NOT NULL, 
   age INT NOT NULL );
