Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. /*
  2. Table to hold Department details
  3. Master table for employees
  4. */
  5.  
  6. CREATE TABLE Departments(
  7. department_id VARCHAR(5) PRIMARY KEY,
  8. department_name VARCHAR(20) NOT NULL,
  9. hq_location VARCHAR(100)
  10. );
  11.  
  12. INSERT INTO 'Departments' ('department_id','department_name','hq_location') VALUES ('D01', 'Accounts', 'Hyderabad');
  13. INSERT INTO 'Departments' ('department_id','department_name','hq_location') VALUES ('D02', 'Sales', 'Delhi');
  14. INSERT INTO 'Departments' ('department_id','department_name','hq_location') VALUES ('D03', 'Front-office', 'Mumbai');
  15. INSERT INTO 'Departments' ('department_id','department_name','hq_location') VALUES ('D04', 'Technical', 'Mumbai');
  16. INSERT INTO 'Departments' ('department_id','department_name','hq_location') VALUES ('D05', 'Billing', 'Delhi');
  17.  
  18. /*
  19. Table to hold Designation details
  20. Master table for employees
  21. */
  22.  
  23. CREATE TABLE Designation(
  24. designation_id INT PRIMARY KEY,
  25. designation_title VARCHAR(30) NOT NULL
  26. );
  27.  
  28. INSERT INTO 'Designation' ('designation_id','designation_title') VALUES (100, 'Accounts Manager');
  29. INSERT INTO 'Designation' ('designation_id','designation_title') VALUES (110, 'Accountant');
  30. INSERT INTO 'Designation' ('designation_id','designation_title') VALUES (101, 'Jr Accountant');
  31. INSERT INTO 'Designation' ('designation_id','designation_title') VALUES (200, 'Sales Manager');
  32. INSERT INTO 'Designation' ('designation_id','designation_title') VALUES (300, 'FO Manager');
  33. INSERT INTO 'Designation' ('designation_id','designation_title') VALUES (400, 'Technical Manager');
  34.  
  35. /*
  36. Table to hold Employees data
  37. */
  38. CREATE TABLE Employees(
  39. employee_id INT PRIMARY KEY,
  40. first_name VARCHAR(200) NOT NULL,
  41. last_name VARCHAR(100),
  42. department_code VARCHAR(5),
  43. designation_code INT,
  44. salary INT NOT NULL,
  45. FOREIGN KEY(department_code) REFERENCES Departments(department_id),
  46. FOREIGN KEY(designation_code) REFERENCES Designation(designation_id)
  47. );
  48.  
  49. INSERT INTO 'Employees' ('employee_id','first_name','last_name', department_code,designation_code, salary) VALUES (1, 'Ram', 'K.', 'D01', 100, 50000);
  50. INSERT INTO 'Employees' ('employee_id','first_name','last_name', department_code,designation_code, salary) VALUES (2, 'Shyam', 'P.', 'D01', 101, 500);
  51. INSERT INTO 'Employees' ('employee_id','first_name','last_name', department_code,designation_code, salary) VALUES (3, 'Xabc', 'B.', 'D01', 110, 5000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement