写一个化妆品销售系统的数据库和表的sql语句
时间: 2023-08-31 21:26:36 浏览: 169
商品销售数据库SQL语句.doc
### 回答1:
CREATE DATABASE makeup_sales;CREATE TABLE customers (
customer_id INT AUTO_INCREMENT,
first_name VARCHAR(50) NOT NULL,
last_name VARCHAR(50) NOT NULL,
email VARCHAR(50) NOT NULL,
PRIMARY KEY (customer_id)
);CREATE TABLE products (
product_id INT AUTO_INCREMENT,
product_name VARCHAR(50) NOT NULL,
price DECIMAL(5,2) NOT NULL,
PRIMARY KEY (product_id)
);CREATE TABLE orders (
order_id INT AUTO_INCREMENT,
customer_id INT NOT NULL,
product_id INT NOT NULL,
quantity INT NOT NULL,
order_date DATETIME NOT NULL,
PRIMARY KEY (order_id),
FOREIGN KEY (customer_id) REFERENCES customers (customer_id) ON DELETE CASCADE,
FOREIGN KEY (product_id) REFERENCES products (product_id) ON DELETE CASCADE
);
### 回答2:
数据库和表的SQL语句如下:
创建数据库:
CREATE DATABASE makeup_system;
使用数据库:
USE makeup_system;
创建表:产品表(product)
CREATE TABLE product (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
brand VARCHAR(50) NOT NULL,
category VARCHAR(50) NOT NULL,
price DECIMAL(10,2) NOT NULL,
inventory INT NOT NULL
);
创建表:订单表(order)
CREATE TABLE order (
id INT AUTO_INCREMENT PRIMARY KEY,
customer_name VARCHAR(100) NOT NULL,
product_id INT NOT NULL,
quantity INT NOT NULL,
order_date DATE NOT NULL,
total_price DECIMAL(10,2) NOT NULL,
FOREIGN KEY (product_id) REFERENCES product(id)
);
创建表:客户表(customer)
CREATE TABLE customer (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
email VARCHAR(100) NOT NULL,
phone_number VARCHAR(20) NOT NULL
);
创建表:库存表(inventory)
CREATE TABLE inventory (
product_id INT NOT NULL,
quantity INT NOT NULL,
FOREIGN KEY (product_id) REFERENCES product(id)
);
创建表:员工表(employee)
CREATE TABLE employee (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
position VARCHAR(50) NOT NULL,
salary DECIMAL(10,2) NOT NULL,
hire_date DATE NOT NULL
);
以上是一个化妆品销售系统的数据库和表的SQL语句。其中包括了产品表、订单表、客户表、库存表和员工表。每个表都有相应的字段来存储对应的信息,以便实现化妆品销售系统的功能。
### 回答3:
以下是一个简单的化妆品销售系统的数据库和表的SQL语句示例:
首先,我们创建一个名为"cosmetics_sales"的数据库:
CREATE DATABASE cosmetics_sales;
接下来,在这个数据库中创建以下表:
1. 顾客表(customers):
CREATE TABLE customers (
id INT PRIMARY KEY,
name VARCHAR(100),
address VARCHAR(200),
email VARCHAR(100),
phone VARCHAR(20)
);
2. 产品表(products):
CREATE TABLE products (
id INT PRIMARY KEY,
name VARCHAR(100),
brand VARCHAR(100),
price DECIMAL(10, 2),
quantity INT
);
3. 订单表(orders):
CREATE TABLE orders (
id INT PRIMARY KEY,
customer_id INT,
product_id INT,
quantity INT,
order_date DATE,
FOREIGN KEY (customer_id) REFERENCES customers(id),
FOREIGN KEY (product_id) REFERENCES products(id)
);
4. 销售员表(salespersons):
CREATE TABLE salespersons (
id INT PRIMARY KEY,
name VARCHAR(100),
email VARCHAR(100),
phone VARCHAR(20)
);
5. 销售记录表(sales_records):
CREATE TABLE sales_records (
id INT PRIMARY KEY,
order_id INT,
salesperson_id INT,
sale_date DATE,
FOREIGN KEY (order_id) REFERENCES orders(id),
FOREIGN KEY (salesperson_id) REFERENCES salespersons(id)
);
这些表包含了化妆品销售系统中的主要实体和关联。顾客表存储顾客信息,产品表存储产品信息,订单表存储订单信息,销售员表存储销售员信息,销售记录表存储销售记录信息。
以上是一个简单的示例,你可以根据具体的业务需求进行修改和扩展。
阅读全文