Perrypackettracer / MySQL

0 stars 0 forks source link

SQL script for inventory managment #3

Open Perrypackettracer opened 9 months ago

Perrypackettracer commented 9 months ago

Certainly! Below is a basic SQL script for creating an Inventory Management Database. This script defines tables for products, purchases, orders, and suppliers. You can customize it further based on your specific requirements:

-- Create the InventoryManager database
CREATE DATABASE InventoryManager;
USE InventoryManager;

-- Create the Products table
CREATE TABLE products (
    product_id INT PRIMARY KEY AUTO_INCREMENT,
    product_name VARCHAR(100) NOT NULL,
    category VARCHAR(50),
    quantity_in_stock INT,
    unit_price DECIMAL(10, 2)
);

-- Create the Suppliers table
CREATE TABLE suppliers (
    supplier_id INT PRIMARY KEY AUTO_INCREMENT,
    supplier_name VARCHAR(100) NOT NULL,
    contact_name VARCHAR(50),
    contact_email VARCHAR(100)
);

-- Create the Purchases table
CREATE TABLE purchases (
    purchase_id INT PRIMARY KEY AUTO_INCREMENT,
    product_id INT,
    supplier_id INT,
    purchase_date DATE,
    quantity_purchased INT,
    FOREIGN KEY (product_id) REFERENCES products(product_id),
    FOREIGN KEY (supplier_id) REFERENCES suppliers(supplier_id)
);

-- Create the Orders table
CREATE TABLE orders (
    order_id INT PRIMARY KEY AUTO_INCREMENT,
    product_id INT,
    order_date DATE,
    quantity_ordered INT,
    FOREIGN KEY (product_id) REFERENCES products(product_id)
);

Explanation:

Feel free to modify or expand this schema to suit your specific inventory management needs! 📦📊

Source: Conversation with Bing, 2/4/2024 (1) How to Make an Awesome Inventory Management Application in PHP and MySQL. https://www.freecodecamp.org/news/making-an-awesome-inventory-management-application-in-php-and-mysql-from-start-to-finish-90bc5996680a/. (2) Javascript Inventory Management System (Free Download) - Code Boxx. https://code-boxx.com/inventory-management-system-javascript/. (3) Powershell Script to Collect SQL Server Inventory. https://www.mssqltips.com/sqlservertip/5931/powershell-script-to-collect-sql-server-inventory/. (4) SQL Server Sample Database. https://www.sqlservertutorial.net/sql-server-sample-database/. (5) Creating a Database Model for an Inventory Management System. https://www.vertabelo.com/blog/data-model-for-inventory-management-system/.