-- 创建员工表CREATE TABLE IF NOT EXISTS employee ( id_card_no CHAR(18) PRIMARY KEY, name VARCHAR(20) NOT NULL, job_type VARCHAR(20) NOT NULL, phone VARCHAR(11), address VARCHAR(100));-- 创建会员表CREATE TABLE IF NOT EXISTS member ( phone VARCHAR(11) PRIMARY KEY, name VARCHAR(20) NOT NULL, discount DECIMAL(3,2) DEFAULT 1.00);-- 创建项目表CREATE TABLE IF NOT EXISTS project ( name VARCHAR(50) PRIMARY KEY, manager VARCHAR(20), price DECIMAL(7,2) NOT NULL);-- 创建预约单表CREATE TABLE IF NOT EXISTS reservation ( id INT AUTO_INCREMENT PRIMARY KEY, phone VARCHAR(11) NOT NULL, reservation_date DATE NOT NULL, project_name VARCHAR(50) NOT NULL, duration INT NOT NULL, FOREIGN KEY (phone) REFERENCES member(phone), FOREIGN KEY (project_name) REFERENCES project(name));-- 创建消费表CREATE TABLE IF NOT EXISTS consumption ( id INT AUTO_INCREMENT PRIMARY KEY, phone VARCHAR(11) NOT NULL, project_name VARCHAR(50) NOT NULL, amount DECIMAL(7,2) NOT NULL, consumption_date DATE NOT NULL, FOREIGN KEY (phone) REFERENCES member(phone), FOREIGN KEY (project_name) REFERENCES project(name));
时间: 2024-04-03 16:34:04 浏览: 79
好的,以下是几组数据插入这些表中的示例 SQL 语句:
-- 插入员工数据
INSERT INTO employee (id_card_no, name, job_type, phone, address) VALUES
('123456789012345678', '张三', '理疗师', '13888888888', '北京市朝阳区'),
('234567890123456789', '李四', '营销经理', '13999999999', '北京市海淀区'),
('345678901234567890', '王五', '后勤保障', '13666666666', '北京市东城区');
-- 插入会员数据
INSERT INTO member (phone, name, discount) VALUES
('13888888888', '张三', 0.95),
('13999999999', '李四', 0.90),
('13666666666', '王五', 0.85);
-- 插入项目数据
INSERT INTO project (name, manager, price) VALUES
('针灸', '张三', 100.00),
('推拿', '李四', 80.00),
('拔罐', '王五', 60.00);
-- 插入预约单数据
INSERT INTO reservation (phone, reservation_date, project_name, duration) VALUES
('13888888888', '2022-01-01', '针灸', 60),
('13999999999', '2022-01-02', '推拿', 90),
('13666666666', '2022-01-03', '拔罐', 30);
-- 插入消费数据
INSERT INTO consumption (phone, project_name, amount, consumption_date) VALUES
('13888888888', '针灸', 100.00, '2022-01-01'),
('13999999999', '推拿', 72.00, '2022-01-02'),
('13666666666', '拔罐', 51.00, '2022-01-03');
阅读全文