0% found this document useful (0 votes)
15 views9 pages

IT Assignment

The document outlines the structure and data for two database tables: Department and Employee, detailing their columns, data types, and constraints. It includes SQL commands for creating the tables, inserting initial data, and a query to display employee details along with their department and location. Additionally, it mentions the creation of forms for data management and provides references for further reading on database design and SQL commands.

Uploaded by

kingbg80
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views9 pages

IT Assignment

The document outlines the structure and data for two database tables: Department and Employee, detailing their columns, data types, and constraints. It includes SQL commands for creating the tables, inserting initial data, and a query to display employee details along with their department and location. Additionally, it mentions the creation of forms for data management and provides references for further reading on database design and SQL commands.

Uploaded by

kingbg80
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

Assignment Submission

Name: Arush pratap singh

Class: 10th

Section: E

Roll Number: 10
Table Structure
Department Table Structure:

Column Name Data Type Constraints

Department ID INT PRIMARY


KEY

Department VARCHAR(5 NOT NULL


Name 0)

Location VARCHAR(5
0)

This table is used to store the details of various departments within an organization.
It includes a unique identifier for each department (Department ID), the name of the
department (Department Name), and its location. This structure ensures that each
department's information is easily accessible and manageable.
Employee Table Structure:

Column Data Type Constraints


Name

Employee ID INT PRIMARY KEY

First Name VARCHAR(5 NOT NULL


0)

Last Name VARCHAR(5


0)

Email VARCHAR(1 UNIQUE, NOT NULL


00)

Phone VARCHAR(1 UNIQUE


5)

Salary DECIMAL(10,
2)

Department INT FOREIGN KEY REFERENCES


ID Department(Department ID)
The Employee table stores personal and professional information about employees,
including their unique ID, name, contact information, salary, and the department
they are associated with. This ensures proper linking and organization of employee
data.

Department Table Data:

DepartmentI DepartmentNa Location


D me

1 IT New York

2 HR Los
Angeles

3 Finance Chicago

The data in the Department table represents three departments in an organization:


IT, HR, and Finance. Each department has a unique ID, a name, and a location. This
data can be expanded as more departments are added to the organization.
Employee Table Data:

Employee FirstNa LastNa Email Phone Salary Departmen


ID me me tID

101 Alice Brown alice@company 123456 50000 1


.com 7890 .00

102 Bob Smith bob@company. 987654 60000 1


com 3210 .00

103 Carol Davis carol@company 543216 45000 2


.com 7890 .00

104 David Johnso david@compan 654321 48000 2


n y.com 7890 .00

The Employee table data contains details of four employees, including their ID,
name, email, phone number, salary, and the department they are working in. This
table helps to track employee information efficiently.
DDL Commands (Data Definition Language):
Create Table (Department):
“CREATE TABLE Department (
Department ID INT PRIMARY KEY,
Department Name VARCHAR(50) NOT NULL,
Location VARCHAR(50)
);”

This command creates the Department table with columns for Department ID,
Department Name, and Location. It ensures that the DepartmentID column serves
as the unique identifier for each department.
Create Table (Employee):
“CREATE TABLE Employee (
Employee ID INT PRIMARY KEY,
First Name VARCHAR(50) NOT NULL,
Last Name VARCHAR(50),
Email VARCHAR(100) UNIQUE NOT NULL,
Phone VARCHAR(15) UNIQUE,
Salary DECIMAL(10, 2),
Department ID INT,
FOREIGN KEY (Department ID) REFERENCES Department(Department
ID)
);”
This command creates the Employee table with all necessary columns, including a
foreign key to ensure that each employee is associated with a valid department.

DML Commands (Data Manipulation Language):


Insert Data into Department Table:
“INSERT INTO Department (Department ID, Department Name,
Location)
VALUES (1, 'IT', 'New York'),
(2, 'HR', 'Los Angeles'),
(3, 'Finance', 'Chicago');”
This command populates the Department table with initial data,
representing three departments.
Insert Data into Employee Table:
“INSERT INTO Employee (Employee ID, First Name, Last Name, Email,
Phone, Salary, Department ID)
VALUES (101, 'Alice', 'Brown', '[email protected]', '1234567890',
50000.00, 1),
(102, 'Bob', 'Smith', '[email protected]', '9876543210', 60000.00,
1),
(103, 'Carol', 'Davis', '[email protected]', '5432167890',
45000.00, 2),
(104, 'David', 'Johnson', '[email protected]', '6543217890',
48000.00, 2);”
This command inserts employee data into the Employee table, ensuring that all
data aligns with the defined structure and constraints.
Data Types:
● INT: Used for numeric values like IDs. It ensures each ID is unique
and numeric for efficient querying.
● VARCHAR(size): Used for string values such as names and email
addresses. The size parameter defines the maximum length.
● DECIMAL(precision, scale): Used for financial data like salaries,
where precision and scale ensure accurate storage and computation.

Report:
SQL Query to Display Employee Details with Department and Location:
“SELECT
e.EmployeeID, e.FirstName, e.LastName, e.Email, e.Phone, e.Salary,
d.DepartmentName, d.Location
FROM Employee e
JOIN Department d ON e.DepartmentID = d.DepartmentID
ORDER BY d.DepartmentName, e.FirstName;”
This query retrieves detailed information about employees, including their
associated department and location, sorted by department and employee names.

Forms:
To manage data effectively, forms can be created for inserting data into
the Employee and Department tables. These forms provide a user-friendly
interface for adding new records to the database. For example, an HTML
form can include fields for all relevant data points, ensuring that all
required fields are completed before submission.

Department Form:
Employee Form:

Thank You!
References:
1. MongoDB Documentation: https://www.mongodb.com/docs/
2. W3Schools SQL Tutorial: https://www.w3schools.com/sql/
3. PostgreSQL Documentation: https://www.postgresql.org/docs/
The references listed above provide comprehensive information on
database design, SQL commands, and best practices for managing
databases. These resources were instrumental in preparing this
assignment.

You might also like