-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_tables.sql
More file actions
45 lines (40 loc) · 1.33 KB
/
create_tables.sql
File metadata and controls
45 lines (40 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
-- OSMS Database Schema Creation Script
-- Drop tables if they exist to start fresh
DROP TABLE IF EXISTS Product;
DROP TABLE IF EXISTS Suppliers;
-- Create Suppliers table
CREATE TABLE Suppliers (
SupplierId INT AUTO_INCREMENT PRIMARY KEY,
CompanyName VARCHAR(255) NOT NULL,
ContactPerson VARCHAR(255),
Email VARCHAR(255),
Phone VARCHAR(50),
Address VARCHAR(255),
City VARCHAR(100),
State VARCHAR(100),
ZipCode VARCHAR(20),
Country VARCHAR(100),
Category VARCHAR(100),
Status VARCHAR(50) DEFAULT 'Active',
Notes TEXT,
JoinedDate DATETIME DEFAULT CURRENT_TIMESTAMP
);
-- Create Product table
CREATE TABLE Product (
ProductId INT AUTO_INCREMENT PRIMARY KEY,
ProductName VARCHAR(255) NOT NULL,
Description TEXT,
Price DECIMAL(10, 2) NOT NULL,
StockQuantity INT NOT NULL DEFAULT 0,
Category VARCHAR(100),
SupplierId INT,
ExpirationDate DATE,
FOREIGN KEY (SupplierId) REFERENCES Suppliers(SupplierId)
);
-- Insert a default supplier for testing
INSERT INTO Suppliers (CompanyName, ContactPerson, Email, Phone, Address, City, State, Country, Category)
VALUES ('Default Supplier', 'John Doe', 'contact@defaultsupplier.com', '123-456-7890', '123 Main St', 'New York', 'NY', 'USA', 'General');
-- Print tables to verify
SHOW TABLES;
DESCRIBE Product;
DESCRIBE Suppliers;