1+ -- Sample database schema for the Text2SQL MCP Server
2+
3+ -- User management tables
4+ CREATE TABLE IF NOT EXISTS users (
5+ id INTEGER PRIMARY KEY ,
6+ username TEXT NOT NULL UNIQUE,
7+ email TEXT NOT NULL UNIQUE,
8+ full_name TEXT ,
9+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ,
10+ last_login TIMESTAMP ,
11+ is_active BOOLEAN DEFAULT TRUE
12+ );
13+
14+ CREATE TABLE IF NOT EXISTS user_sessions (
15+ session_id TEXT PRIMARY KEY ,
16+ user_id INTEGER NOT NULL ,
17+ start_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ,
18+ end_time TIMESTAMP ,
19+ ip_address TEXT ,
20+ user_agent TEXT ,
21+ FOREIGN KEY (user_id) REFERENCES users(id)
22+ );
23+
24+ -- Product catalog tables
25+ CREATE TABLE IF NOT EXISTS categories (
26+ id INTEGER PRIMARY KEY ,
27+ name TEXT NOT NULL ,
28+ description TEXT ,
29+ parent_id INTEGER ,
30+ FOREIGN KEY (parent_id) REFERENCES categories(id)
31+ );
32+
33+ CREATE TABLE IF NOT EXISTS products (
34+ id INTEGER PRIMARY KEY ,
35+ name TEXT NOT NULL ,
36+ description TEXT ,
37+ price DECIMAL (10 , 2 ) NOT NULL ,
38+ stock_quantity INTEGER DEFAULT 0 ,
39+ category_id INTEGER ,
40+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ,
41+ updated_at TIMESTAMP ,
42+ FOREIGN KEY (category_id) REFERENCES categories(id)
43+ );
44+
45+ CREATE TABLE IF NOT EXISTS product_attributes (
46+ id INTEGER PRIMARY KEY ,
47+ product_id INTEGER NOT NULL ,
48+ name TEXT NOT NULL ,
49+ value TEXT NOT NULL ,
50+ FOREIGN KEY (product_id) REFERENCES products(id)
51+ );
52+
53+ -- Order management tables
54+ CREATE TABLE IF NOT EXISTS orders (
55+ id INTEGER PRIMARY KEY ,
56+ user_id INTEGER NOT NULL ,
57+ status TEXT NOT NULL ,
58+ total_amount DECIMAL (10 , 2 ) NOT NULL ,
59+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ,
60+ updated_at TIMESTAMP ,
61+ FOREIGN KEY (user_id) REFERENCES users(id)
62+ );
63+
64+ CREATE TABLE IF NOT EXISTS order_items (
65+ id INTEGER PRIMARY KEY ,
66+ order_id INTEGER NOT NULL ,
67+ product_id INTEGER NOT NULL ,
68+ quantity INTEGER NOT NULL ,
69+ price DECIMAL (10 , 2 ) NOT NULL ,
70+ FOREIGN KEY (order_id) REFERENCES orders(id),
71+ FOREIGN KEY (product_id) REFERENCES products(id)
72+ );
73+
74+ -- Insert sample data
75+ INSERT INTO users (username, email, full_name) VALUES
76+ (' john_doe' , ' john@example.com' , ' John Doe' ),
77+ (' jane_smith' , ' jane@example.com' , ' Jane Smith' ),
78+ (' bob_johnson' , ' bob@example.com' , ' Bob Johnson' );
79+
80+ INSERT INTO categories (name, description) VALUES
81+ (' Electronics' , ' Electronic devices and accessories' ),
82+ (' Clothing' , ' Apparel and fashion items' ),
83+ (' Books' , ' Books and publications' );
84+
85+ INSERT INTO products (name, description, price, stock_quantity, category_id) VALUES
86+ (' Smartphone' , ' Latest smartphone with advanced features' , 699 .99 , 50 , 1 ),
87+ (' Laptop' , ' High-performance laptop for professionals' , 1299 .99 , 30 , 1 ),
88+ (' T-shirt' , ' Cotton t-shirt, various colors' , 19 .99 , 100 , 2 ),
89+ (' Jeans' , ' Denim jeans, slim fit' , 49 .99 , 75 , 2 ),
90+ (' Programming Guide' , ' Comprehensive programming reference' , 39 .99 , 25 , 3 );
91+
92+ INSERT INTO orders (user_id, status, total_amount) VALUES
93+ (1 , ' completed' , 749 .98 ),
94+ (2 , ' processing' , 1299 .99 ),
95+ (3 , ' completed' , 89 .98 );
96+
97+ INSERT INTO order_items (order_id, product_id, quantity, price) VALUES
98+ (1 , 1 , 1 , 699 .99 ),
99+ (1 , 3 , 1 , 49 .99 ),
100+ (2 , 2 , 1 , 1299 .99 ),
101+ (3 , 3 , 2 , 39 .99 ),
102+ (3 , 5 , 1 , 9 .99 );
0 commit comments