diff --git a/SQL Basics Create Table and Insert Into b/SQL Basics Create Table and Insert Into index 6a236ef..7fd8380 100644 --- a/SQL Basics Create Table and Insert Into +++ b/SQL Basics Create Table and Insert Into @@ -1,42 +1,40 @@ +-- Create Table: EmployeeDemographics +CREATE TABLE EmployeeDemographics ( + EmployeeID INT PRIMARY KEY, + FirstName VARCHAR(50) NOT NULL, + LastName VARCHAR(50) NOT NULL, + Age INT CHECK (Age > 0), + Gender VARCHAR(50) CHECK (Gender IN ('Male', 'Female')) +); -Table 1 Query: -Create Table EmployeeDemographics -(EmployeeID int, -FirstName varchar(50), -LastName varchar(50), -Age int, -Gender varchar(50) -) +-- Create Table: EmployeeSalary +CREATE TABLE EmployeeSalary ( + EmployeeID INT PRIMARY KEY, + JobTitle VARCHAR(50) NOT NULL, + Salary INT CHECK (Salary > 0), + FOREIGN KEY (EmployeeID) REFERENCES EmployeeDemographics(EmployeeID) +); -Table 2 Query: -Create Table EmployeeSalary -(EmployeeID int, -JobTitle varchar(50), -Salary int -) +-- Insert Data into EmployeeDemographics +INSERT INTO EmployeeDemographics (EmployeeID, FirstName, LastName, Age, Gender) VALUES + (1001, 'Jim', 'Halpert', 30, 'Male'), + (1002, 'Pam', 'Beasley', 30, 'Female'), + (1003, 'Dwight', 'Schrute', 29, 'Male'), + (1004, 'Angela', 'Martin', 31, 'Female'), + (1005, 'Toby', 'Flenderson', 32, 'Male'), + (1006, 'Michael', 'Scott', 35, 'Male'), + (1007, 'Meredith', 'Palmer', 32, 'Female'), + (1008, 'Stanley', 'Hudson', 38, 'Male'), + (1009, 'Kevin', 'Malone', 31, 'Male'); - - -Table 1 Insert: -Insert into EmployeeDemographics VALUES -(1001, 'Jim', 'Halpert', 30, 'Male'), -(1002, 'Pam', 'Beasley', 30, 'Female'), -(1003, 'Dwight', 'Schrute', 29, 'Male'), -(1004, 'Angela', 'Martin', 31, 'Female'), -(1005, 'Toby', 'Flenderson', 32, 'Male'), -(1006, 'Michael', 'Scott', 35, 'Male'), -(1007, 'Meredith', 'Palmer', 32, 'Female'), -(1008, 'Stanley', 'Hudson', 38, 'Male'), -(1009, 'Kevin', 'Malone', 31, 'Male') - -Table 2 Insert: -Insert Into EmployeeSalary VALUES -(1001, 'Salesman', 45000), -(1002, 'Receptionist', 36000), -(1003, 'Salesman', 63000), -(1004, 'Accountant', 47000), -(1005, 'HR', 50000), -(1006, 'Regional Manager', 65000), -(1007, 'Supplier Relations', 41000), -(1008, 'Salesman', 48000), -(1009, 'Accountant', 42000) +-- Insert Data into EmployeeSalary +INSERT INTO EmployeeSalary (EmployeeID, JobTitle, Salary) VALUES + (1001, 'Salesman', 45000), + (1002, 'Receptionist', 36000), + (1003, 'Salesman', 63000), + (1004, 'Accountant', 47000), + (1005, 'HR', 50000), + (1006, 'Regional Manager', 65000), + (1007, 'Supplier Relations', 41000), + (1008, 'Salesman', 48000), + (1009, 'Accountant', 42000);