-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpos_system.sql
More file actions
63 lines (55 loc) · 1.82 KB
/
pos_system.sql
File metadata and controls
63 lines (55 loc) · 1.82 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
CREATE DATABASE IF NOT EXISTS pos_system;
USE pos_system;
-- for maintaining user data
CREATE TABLE users (
id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(255),
username VARCHAR(255) UNIQUE,
password VARCHAR(255),
role VARCHAR(255)
);
-- insert admin user
INSERT INTO users (name, username, password, role) VALUES ('Admin', 'admin', 'admin', 'Manager');
-- insert staff user
INSERT INTO users (name, username, password, role) VALUES ('Staff', 'staff', 'staff', 'SalesAssistant');
-- for maintaining categories in database
CREATE TABLE categories (
code INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255),
description VARCHAR(255)
);
-- for maintaining products in database
CREATE TABLE products (
code INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255),
description VARCHAR(255),
stockQuantity INT,
price DECIMAL(10, 2),
categoryCode INT,
alertQuantity INT,
dateTracked VARCHAR(255),
FOREIGN KEY (categoryCode) REFERENCES categories(code) ON UPDATE CASCADE ON DELETE CASCADE
);
CREATE TABLE orders (
orderID INT AUTO_INCREMENT PRIMARY KEY,
customerName VARCHAR(255),
totalAmount DOUBLE,
orderDate VARCHAR(255),
status VARCHAR(50) DEFAULT 'Completed'
);
-- Store settings configuration
CREATE TABLE settings (
k VARCHAR(255) PRIMARY KEY,
v VARCHAR(255)
);
INSERT INTO settings (k, v) VALUES ('store_name', 'Modern POS System');
INSERT INTO settings (k, v) VALUES ('currency_symbol', '$');
INSERT INTO settings (k, v) VALUES ('tax_rate', '0.0');
CREATE TABLE orderedItems (
itemID INT PRIMARY KEY AUTO_INCREMENT,
orderID INT,
productCode INT ,
quantityOrdered INT,
FOREIGN KEY (orderID) REFERENCES orders(orderID) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (productcode) REFERENCES products(code) ON UPDATE CASCADE ON DELETE CASCADE
);