SQL Basics: Creating Employee Details and Salary Tables Using Create And Insert Function

Egemolu Goodnews
4 min readOct 3, 2023

--

Introduction

In the vast realm of data analytics, SQL (Structured Query Language) stands as a fundamental pillar. As I embarked on my journey to dive deeper into this world, I recently undertook an assignment that involved creating and populating tables to store employee information. In this post, I’ll share my experience and guide you through the process of creating two vital tables: Employee Details and Employee Salary.

Understanding the Task

The task was clear: create two tables, one to store employee details such as name, age, and gender, and another to store salary information including salary amount and job title. The challenge was to understand the structure of the data and translate it into SQL commands.

First I opened my SQL Server

I right-clicked on Database to create a new Database

Then i named the data base with any name of my choice, here i names it SQL Practice.

Creating the Employee Details Table

Creating the Employee Details table was the first thing i did. Here’s how I did it:

CREATE TABLE EmployeeDetails
(EmployeeID Int,
FirstName varchar (50),
LastNaame varchar (50),
Gender varchar (50),
Age int )

After which I clicked on Execute to run the code and a successful message came back showing that there was no error with the code.

NB: The varchar is indicated to tell the program that what should be entered in the column is text while the int which indicates the integer shows that only the number should be there. The (50) indicates that the characters should not exceed 50.

To view the table created, look at the left-hand side of the screen, you will see the name of the table as dbo.Employeedetails. Right-click on it and select. ‘select top 1000 Rows’

Here is our new table

Next, I moved on to the Employee Salary table

Follow same Create Table EmployeeSalary to create the salary table, it will look like this.

Sometimes the details in the table might not show, just right-click and click on refresh as in the picture below.

Populating the Tables

Once the tables were created, it was time to populate them with data. I utilized the INSERT INTO statement to achieve this:

Here is the command i used

INSERT INTO EmployeeDetails VALUES
(1001, ‘Egemolu’, ‘Goodnews’, ‘Male’, 30),
(1002, ‘Nzerem’, ‘Chris’, ‘Male’, 31),
(1003, ‘Ogbonna’, ‘Precious’, ‘Female’, 28),
(1004, ‘Ndubueze’, ‘Bede’, ‘Male’, 30),
(1005, ‘Eze’, ‘Tochukwu’, ‘Male’, 29),
(1006, ‘Egemolu’, ‘Goodnews’, ‘Male’, 30),
(1007, ‘Nzerem’, ‘Chris’, ‘Male’, 31),
(1008, ‘Ogbonna’, ‘Precious’, ‘Female’, 28),
(1009, ‘Ndubueze’, ‘Bede’, ‘Male’, 30),
(10010, ‘Eze’, ‘Tochukwu’, ‘Male’, 29)

Here is the result

I also did for the employee salarytable

This knowledge forms the foundation of efficient data management, enabling businesses to store, retrieve, and analyze information effectively.

Through this experience, I not only honed my SQL skills but also realized the practical importance of database design. As I progress in my data analytics journey, mastering SQL basics like these empowers me to tackle more complex challenges in the world of data.

With these newfound skills, I’m better equipped to handle real-world scenarios, understanding that even the most intricate databases are built upon simple, yet powerful, SQL commands.

About the Author

Hello, I’m Goodnews, a passionate data enthusiast with a knack for turning numbers into insights. With a background in Sales, Product and now Data, I’m dedicated to harnessing the power of data to drive informed decisions. Connect with me let’s embark on data-driven adventures together!

Thank You!!

--

--