用mysql写出宠物店领养寄养系统
时间: 2024-01-25 15:03:52 浏览: 81
这里提供一个简单的宠物店领养寄养系统的MySQL数据库设计和表结构:
```
-- 用户表
CREATE TABLE users (
id INT PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(50) NOT NULL,
password VARCHAR(50) NOT NULL,
realname VARCHAR(50) NOT NULL,
gender ENUM('male', 'female') NOT NULL,
phone VARCHAR(20) NOT NULL,
email VARCHAR(50) NOT NULL
);
-- 宠物表
CREATE TABLE pets (
id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(50) NOT NULL,
type ENUM('dog', 'cat', 'other') NOT NULL,
breed VARCHAR(50) NOT NULL,
gender ENUM('male', 'female') NOT NULL,
age INT NOT NULL,
color VARCHAR(50) NOT NULL,
image VARCHAR(255) NOT NULL
);
-- 领养申请表
CREATE TABLE adoption (
id INT PRIMARY KEY AUTO_INCREMENT,
user_id INT NOT NULL,
pet_id INT NOT NULL,
apply_time DATETIME NOT NULL,
status ENUM('pending', 'approved', 'rejected') NOT NULL,
FOREIGN KEY (user_id) REFERENCES users(id),
FOREIGN KEY (pet_id) REFERENCES pets(id)
);
-- 寄养申请表
CREATE TABLE foster (
id INT PRIMARY KEY AUTO_INCREMENT,
user_id INT NOT NULL,
pet_id INT NOT NULL,
start_time DATETIME NOT NULL,
end_time DATETIME NOT NULL,
status ENUM('pending', 'approved', 'rejected') NOT NULL,
FOREIGN KEY (user_id) REFERENCES users(id),
FOREIGN KEY (pet_id) REFERENCES pets(id)
);
-- 订单表
CREATE TABLE orders (
id INT PRIMARY KEY AUTO_INCREMENT,
user_id INT NOT NULL,
pet_id INT NOT NULL,
order_type ENUM('adoption', 'foster') NOT NULL,
order_time DATETIME NOT NULL,
status ENUM('pending', 'paid', 'cancelled', 'completed') NOT NULL,
FOREIGN KEY (user_id) REFERENCES users(id),
FOREIGN KEY (pet_id) REFERENCES pets(id)
);
-- 支付表
CREATE TABLE payment (
id INT PRIMARY KEY AUTO_INCREMENT,
order_id INT NOT NULL,
payment_method ENUM('paypal', 'credit_card', 'wechat', 'alipay') NOT NULL,
amount DECIMAL(8, 2) NOT NULL,
payment_time DATETIME NOT NULL,
FOREIGN KEY (order_id) REFERENCES orders(id)
);
-- 评价表
CREATE TABLE evaluation (
id INT PRIMARY KEY AUTO_INCREMENT,
order_id INT NOT NULL,
content TEXT NOT NULL,
evaluation_time DATETIME NOT NULL,
FOREIGN KEY (order_id) REFERENCES orders(id)
);
-- 管理员表
CREATE TABLE admins (
id INT PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(50) NOT NULL,
password VARCHAR(50) NOT NULL
);
```
以上是一个简单的宠物店领养寄养系统的MySQL数据库设计和表结构。其中,users表、pets表、adoption表、foster表、orders表、payment表和evaluation表为主要的表结构,admins表为管理员信息表。这里只提供了表结构,实际开发中还需要对表之间的关系进行处理,如添加外键等。
阅读全文