Database
Database
Database
-- Create the Students table with a primary key ( this is comments for your understanding
not part of code.)
CREATE TABLE Students (
student_id INT PRIMARY KEY,
first_name VARCHAR(50),
last_name VARCHAR(50),
dob DATE
);
-- Create the Courses table with a foreign key referencing Students ( this is comments for
your understanding not part of code.)
CREATE TABLE Courses (
course_id INT PRIMARY KEY,
course_name VARCHAR(100),
instructor VARCHAR(100),
student_id INT,
FOREIGN KEY (student_id) REFERENCES Students(student_id)
);
-- Insert data into the Departments table ( this is comments for your
understanding not part of code.)
INSERT INTO Departments (DepartmentID, DepartmentName)
VALUES
(1, 'HR'),
(2, 'Engineering'),
(3, 'Finance');
-- Insert data into the JobTitles table ( this is comments for your
understanding not part of code.)
INSERT INTO JobTitles (JobTitleID, JobTitleName)
VALUES
(1, 'Manager'),
(2, 'Software Engineer'),
(3, 'Accountant');
-- Insert data into the Employees table ( this is comments for your
understanding not part of code.)
INSERT INTO Employees (EmployeeID, FirstName, LastName,
DepartmentID, JobTitleID, ContactInfoID)
VALUES
(1, 'John', 'Doe', 1, 1, 1),
(2, 'Jane', 'Smith', 2, 2, 2),
(3, 'Alice', 'Johnson', 1, 2, 3);
-- Insert data into the Salaries table ( this is comments for your
understanding not part of code.)
INSERT INTO Salaries (SalaryID, EmployeeID, SalaryAmount)
VALUES
(1, 1, 75000),
(2, 2, 80000),
(3, 3, 70000);
-- Insert data into the Benefits table ( this is comments for your
understanding not part of code.)
INSERT INTO Benefits (BenefitID, EmployeeID, BenefitName)
VALUES
(1, 1, 'Health Insurance'),
(2, 2, '401(k) Matching'),
(3, 3, 'Paid Time Off');
-- Insert data into the ContactInfo table ( this is comments for your
understanding not part of code.)
INSERT INTO ContactInfo (ContactInfoID, EmployeeID, Email,
PhoneNumber)
VALUES
(1, 1, '[email protected]', '123-456-7890'),
(2, 2, '[email protected]', '987-654-3210'),
(3, 3, '[email protected]', '555-123-4567');