To create a database for employees and products, you can use SQL to define the necessary tables and relationships between them. Here’s an example SQL script that creates such a database with two tables: `Employees` and `Products`. The `Employees` table will store information about employees, and the `Products` table will store information about products.
— Create a new database (if it doesn’t already exist)
CREATE DATABASE IF NOT EXISTS EmployeeProductDB;
— Switch to the newly created database
USE EmployeeProductDB;
— Create the Employees table
CREATE TABLE Employees (
EmployeeID INT PRIMARY KEY AUTO_INCREMENT,
FirstName VARCHAR(50),
LastName VARCHAR(50),
Email VARCHAR(100),
PhoneNumber VARCHAR(15),
HireDate DATE,
Salary DECIMAL(10, 2)
);
— Create the Products table
CREATE TABLE Products (
ProductID INT PRIMARY KEY AUTO_INCREMENT,
ProductName VARCHAR(100),
Description TEXT,
Price DECIMAL(10, 2),
StockQuantity INT
);
“`
In this example:
– We first create a new database called `EmployeeProductDB` if it doesn’t already exist.
– Then, we use the `USE` statement to switch to the newly created database.
– Next, we create the `Employees` table with columns for employee information such as `EmployeeID`, `FirstName`, `LastName`, `Email`, `PhoneNumber`, `HireDate`, and `Salary`.
– Finally, we create the `Products` table with columns for product information, including `ProductID`, `ProductName`, `Description`, `Price`, and `StockQuantity`. The `ProductID` column is used as the primary key for this table.
You can execute this SQL script using a database management tool like MySQL, PostgreSQL, or Microsoft SQL Server to create your database for employees and products. Remember to adjust the data types and constraints according to your specific requirements.