Database course design supermarket information management system

Table of contents

1. Requirements analysis

1. System requirements analysis and description

1.1.1 System requirements description:

1.1.2 System feasibility analysis:

1.1.3 System application scope:

2. System function structure diagram

3. Business flow chart

2. Conceptual structural design

1. Entity description

2. Local E-R diagram

 2.2.1 Employee page

2.2.2 Inventory page

2.2.3 Warehouse interface 

 2.2.4 Product interface

2.2.5 Product type interface 

 2.2.6 Supplier page

3. Global E-R diagram 

3. Logical structure design

1. Convert E-R diagram to relational model

2. Data dictionary and table structure design (table list and field information list of each table)

3.2.1 Employee information form

3.2.2 Inventory information table

3.2.3 Warehouse information table

3.2.4 Product information table

3.2.5 Product category information table

3.2.6 Supplier information table

4. Database implementation

1. Use SQL statements to complete the creation of the table

4.1.1 Creation of employee table

4.1.2 Creation of inventory information table

4.1.3 Creation of warehouse information table

4.1.4 Creation of product information table

4.1.5 Creation of product type information table

4.1.6 Creation of supplier type information table

2. Use SQL statements to complete the addition of table data

4.2.1 Adding employee table data

4.2.2 Adding inventory table data

4.2.3 Adding warehouse table data

4.2.4 Adding product table data

4.2.5 Adding product type table data

4.2.6 Adding supplier table data

3. Use SQL statements to customize views

4.3.1 View of employee table

4.3.2 View of inventory table

4.3.3 Views of warehouse tables

4.3.4 View of product table

4.3.5 View of product types

4.3.6 View of supplier table

4. Use SQL statements to customize addition, deletion, modification and query operations.

4.4.1 Add table content

4.4.2 Delete table contents

4.4.3 Modify table contents

4.4.4 Search the table

5. Summary


Database course design

Course Name:Database Course Design                            

Design topic:Supermarket information management system                            

professional class:                                                        

student ID:                                                              

student name:                                                               

mentor:                                                                   

year month day

1. Requirements analysis

1. System requirements analysis and description

1.1.1 System requirements description:

       With the development of technology, supermarket competition has entered a new era. The competition between supermarkets is no longer a competition of scale but a competition of technology, talent and management. The improvement of technology and management is the core of supermarket competition, so the market demand for supermarket information management systems is still relatively large.

       Supermarket information management system is a system that manages supermarket information. Its functions include employee management, inventory management, product management, warehouse management and purchase management.

       Employee management: Manage supermarket employee information, including query, update and other functions;

       Inventory management: Code the goods purchased in the supermarket and store them in the warehouse, and conduct shipment management and inventory statistics according to the sales list;

       Product management: Classify the goods purchased from the supermarket and mark the matters that need attention, which can better help supermarket managers manage the supermarket;

       Warehouse management: Allow supermarket managers to better understand the situation of each warehouse;

       Purchase management: Manage supplier information, implement product procurement, and conduct purchase inquiries.

1.1.2 System feasibility analysis:

       There are many large supermarkets in today’s life, which leads to many situations such as too many employees, too much product information, and troublesome warehouse management. If these situations are recorded on paper, it will cost supermarket managers more energy and financial resources, and My supermarket information management system is fast and convenient to query and update sales information through the Internet. It can be done by only one or two people, which can reduce unnecessary expenses and improve query efficiency. In terms of economy and efficiency, my supermarket information management system is feasible.

       And this system is relatively simple, and developers do not need to invest too much energy and time, so from a developer's perspective, this supermarket information management system is feasible.

1.1.3 System application scope:

Can be used in various small and medium-sized supermarkets

2. System function structure diagram

3. Business flow chart

2. Conceptual structural design

1. Entity description

 There are six abstract entities in the supermarket information management system. 

  1. Employee entity attributes: employee number, name, gender, age, position, date of joining;
  2. Inventory entity attributes: inventory number, product number, product name, product price, inventory product quantity, warehouse number, product entry time, product exit time, product exit quantity;
  3. Warehouse entity attributes: warehouse number, warehouse name;
  4. Product entity attributes: product number, name, price, product type;
  5. Product type entity attributes: product type number, type name, product notes;
  6. Supplier entity attributes: supplier number, name, phone number, address.

2. Local E-R diagram

 2.2.1 Employee page

2.2.2 Inventory page

2.2.3 Warehouse interface 

 

 2.2.4 Product interface

2.2.5 Product type interface 

 2.2.6 Supplier page

3. Global E-R diagram 

3. Logical structure design

1. Convert E-R diagram to relational model

        The relationship between suppliers and inventory is a many-to-many relationship. Therefore, the supplier, inventory and supply relationships are designed into the following relationship patterns:

        Supplier (supplier number, name, phone number, address)

       Inventory (inventory number, product number, product name, product price, inventory quantity, warehouse number, product entry time, product exit time, product exit quantity)

        Supply (supplier number, inventory number, supply date, supply price)

        Inventory and warehouse are also many-to-many relationship types. Since the "inventory" relationship model has been given above, you only need to give the relationship model of one warehouse, and the relationship between them is placed in the relationship model:

        Warehouse (warehouse number, warehouse name)

       Employees have a many-to-many relationship with products. Different employees can sell and inquire about different products. Therefore, employees, products, and sales relationships are designed into the following relationship models:

       Employee (employee number, employee name, gender, age, position, date of joining)

       Product (product number, name, price, product type)

       Sales (employee position, product name, price)

       One product type can correspond to multiple products, so there is a one-to-many relationship between products and product types. It can also be expressed using two relational models. Since the "commodity" relationship model has been given above, only the relationship model of the commodity type needs to be given, and the connections between them are placed in this relationship model:

        Product type (product type number, type name, product notes)

        One warehouse manager can manage multiple warehouses, so the management between employees and warehouses is a one-to-many relationship type.

2. Data dictionary and table structure design (table list and field information list of each table)

3.2.1 Employee information form

Field name

type of data

length

constraint

Remark

employee_id

int

6

primary key

employee ID

employee_name

varchar

40

non empty

  employee's name

employee_sex

  varchar

40

non empty

  Employee gender

employee_age

  varchar

100

non empty

  Employee age

employee_title

  varchar

40

non empty

  Employee positions

entry_date

  datetime

  Date of joining

3.2.2 Inventory information table

Field name

type of data

length

constraint

Remark

id

int

1

primary key

Stock number

goods_id

varchar

100

primary key

  Product Number

goods_name

varchar

40

non empty

  product name

goods_price

decimal

(8,4)

non empty

  Product price

store_goods_num

varchar

    40

non empty

 Number of items in stock

storehouse_id

varchar

100

non empty

 Warehouse number

storage_time

datetime

 Restocking time

delivery_time

datetime

  delivery time

delivery_num

varchar

40

 Export quantity

3.2.3 Warehouse information table

Field name

type of data

length

constraint

Remark

storehouse_id

    int

5

primary key

Warehouse number

storehouse_name

varchar

40

non empty

  warehouse name

3.2.4 Product information table

Field name

type of data

    length

constraint

Remark

goods_id

int

1

primary key

Product Number

goods_name

varchar

20

non empty

product name

goods_price

varchar

(6,2)

non empty

Product price

goodtype

varchar

foreign key

Product Category

3.2.5 Product category information table

Field name

type of data

length

constraint

Remark

type_id

int

1

primary key

Item type number

type_name

varchar

20

non empty

Product type name

content

varchar

50

Product type considerations

3.2.6 Supplier information table

Field name

type of data

length

constraint

Remark

Supplier_id

int

1

primary key

 supplier code

Supplier_name

varchar

40

non empty

Supplier name

Supplier_telephone

varchar

20

non empty

Supplier phone number

Supplier_address

varchar

60

non empty

supplier address

4. Database implementation

1. Use SQL statements to complete the creation of the table

4.1.1 Creation of employee table

CREATE TABLE s_employee(

employee_id int UNSIGNED auto_increment,

employee_name VARCHAR(40) NOT NULL,

employee_sex VARCHAR(40) NOT NULL,

employee_age VARCHAR(100) NOT NULL,

employee_title VARCHAR(40) NOT NULL,

entry_date DATE,

PRIMARY KEY(employee_id)

);

4.1.2 Creation of inventory information table

CREATE TABLE `s_stock`(

`id` INT UNSIGNED auto_increment,

`goods_id` VARCHAR(100) NOT NULL,

`goods_name` VARCHAR(40) NOT NULL,

`goods_price` DECIMAL(8,4),

`store_goods_num` VARCHAR(40) NOT NULL,

`storehouse_id` VARCHAR(100) NOT NULL,

`storage_time` date,

`delivery_time` date,

`delivery_num` VARCHAR(40),

PRIMARY KEY (`id`, `goods_id`)

);

4.1.3仓库信息表的创建

CREATE TABLE `s_storehouse`(

`storehouse_id` INT UNSIGNED auto_increment,

`storehouse_name` VARCHAR(40) NOT NULL,

PRIMARY KEY (`storehouse_id`)

)ENGINE=InnoDB DEFAULT charset=utf8;

4.1.4商品信息表的创建

CREATE TABLE s_goods(

goods_id INT PRIMARY KEY auto_increment,

goods_name VARCHAR (20) NOT NULL,

goods_price DECIMAL (6,2) NOT NULL,

goodstype INT,

CONSTRAINT id_fk FOREIGN KEY(goodstype) REFERENCES s_goodstype(type_id)

);

4.1.5商品类型信息表的创建

CREATE TABLE s_goodstype(

type_id INT PRIMARY KEY auto_increment,

type_name VARCHAR (20) NOT NULL,

content VARCHAR (50)

);

4.1.6供应商类型信息表的创建

CREATE TABLE s_supplier(

supplier_id int UNSIGNED auto_increment,

supplier_name VARCHAR(40) NOT NULL,

supplier_telephone VARCHAR (20) NOT NULL,

supplier_address VARCHAR(60) NOT NULL,

PRIMARY KEY(supplier_id)

);

2.使用SQL语句完成表数据的添加

4.2.1员工表数据的添加

insert into s_employee VALUES (629001,'张三','男',28,'登记员','2022-06-20');

insert into s_employee VALUES (629002,'李四','男',34,'仓管','2021-07-10');

insert into s_employee VALUES (629003,'王五','男',45,'财务','2020-04-20');

insert into s_employee VALUES (629004,'李牛','男',24,'货运','2022-09-21');

insert into s_employee VALUES (629005,'马丁','男',28,'搬运','2022-06-20');

insert into s_employee VALUES (629006,'牛七','男',29,'收银员','2021-07-20');

4.2.2库存表数据的添加

INSERT INTO s_stock VALUES (1, 11000,'海飞丝洗发水',65.00,87,22000,'2022-04-07','2022-04-27',20);

INSERT INTO s_stock VALUES (2, 11000,'海飞丝洗发水',65.00,52,22001,'2022-04-07','2022-04-19',10);

INSERT INTO s_stock VALUES (3, 11001,'黑人牙膏',18.00,20,22003,'2021-12-12','2022-01-17',20);

INSERT INTO s_stock VALUES (4, 11002,'丹姿护发素',29.00,103,22003,'2020-11-07','2020-11-11',88);

INSERT INTO s_stock VALUES (5, 11003,'蓝月亮洗衣液',49.00,64,22002,'2021-05-01','2021-06-18',50);

INSERT INTO s_stock VALUES (6, 11004,'洁柔抽纸',69.00,200,22004,'2022-01-01','2022-04-03',180);

INSERT INTO s_stock VALUES (7, 11005,'洗面奶',38.00,370,22005,'2022-02-16','2022-05-27',108);

INSERT INTO s_stock VALUES (8, 11006,'护手霜',25.00,123,22002,'2021-10-01','2021-11-11',108);

INSERT INTO s_stock VALUES (9, 11006,'太谷饼',15.00,103,22004,'2021-11-01','2021-12-11',18);

INSERT INTO s_stock VALUES (10, 11006,'可口可乐',4.00,223,22000,'2022-10-01','2022-11-11',208);

INSERT INTO s_stock VALUES (11, 11006,'电动牙刷',125.00,323,22001,'2021-09-01','2021-09-11',128);

INSERT INTO s_stock VALUES (12, 11006,'香蕉',5.00,456,22000,'2022-09-01','2022-10-11',356);

INSERT INTO s_stock VALUES (13, 11006,'草莓',25.00,234,22003,'2022-02-01','2022-02-11',134);

4.2.3仓库表数据的添加

insert into s_storehouse VALUES (22000,'华中仓库1号');

insert into s_storehouse VALUES (22001,'华东仓库2号');

insert into s_storehouse VALUES (22002,'华南仓库3号');

insert into s_storehouse VALUES (22003,'华西仓库4号');

insert into s_storehouse VALUES (22004,'华北仓库5号');

4.2.4商品表数据的添加

INSERT INTO s_goods VALUES (1,'海飞丝洗发水',65.00,3);

INSERT INTO s_goods VALUES (2,'黑人牙膏',18.00,3);

INSERT INTO s_goods VALUES (3,'丹姿护发素',65.00,3);

INSERT INTO s_goods VALUES (4,'蓝月亮洗衣液',49.00,2);

INSERT INTO s_goods VALUES (5,'洁柔抽纸',69.00,2);

INSERT INTO s_goods VALUES (6,'洗面奶',38.00,3);

INSERT INTO s_goods VALUES (7,'护手霜',25.00,4);

INSERT INTO s_goods VALUES (8,'太谷饼',15.00,6);

INSERT INTO s_goods VALUES (9,'可口可乐',4.00,6);

INSERT INTO s_goods VALUES (10,'电动牙刷',125.00,1);

INSERT INTO s_goods VALUES (11,'香蕉',5.00,5);

INSERT INTO s_goods VALUES (12,'草莓',25.00,5);

4.2.5商品类型表数据的添加

INSERT INTO s_goodstype VALUES (1,'家用电器','电器类商品为高价值商品应重点维护');

INSERT INTO s_goodstype VALUES (2,'日常生活用品','日常生活用品种类复杂注意分类');

INSERT INTO s_goodstype VALUES (3,'洗漱用品','洗头的与洗脸的不要混乱摆放,给顾客造成不便');

INSERT INTO s_goodstype VALUES (4,'护肤品','各品牌护肤品摆放整齐');

INSERT INTO s_goodstype VALUES (5,'生鲜水果','保质期较短货架上的生鲜水果必须要是新鲜的');

INSERT INTO s_goodstype VALUES (6,'食品饮料','注意食品饮料的保质期,过期食品不要出现在货架上');

4.2.6供应商表数据的添加

INSERT INTO s_supplier VALUES (1,'赵六',13456727896,'杭州');

INSERT INTO s_supplier VALUES (2,'孙琪',13678765678,'西安');

INSERT INTO s_supplier VALUES (3,'牛八',13994987689,'福建');

INSERT INTO s_supplier VALUES (4,'李九',13245678967,'郑州');

INSERT INTO s_supplier VALUES (5,'张十',13776789567,'昆明');

INSERT INTO s_supplier VALUES (6,'钱九',13843567779,'重庆');

INSERT INTO s_supplier VALUES (7,'胡七',13564565656,'黑龙江');

3.使用SQL语句自定义创建视图

4.3.1员工表的视图

CREATE VIEW s_employee_view AS SELECT employee_name,employee_age from s_employee;

SELECT * FROM s_employee_view;

4.3.2库存表的视图

CREATE VIEW s_stock_view AS SELECT delivery_time,store_goods_num FROM s_stock;

SELECT * FROM s_stock_view;

4.3.3仓库表的视图

CREATE VIEW s_storehouse_view AS SELECT storehouse_id,storehouse_name FROM s_storehouse;

SELECT * FROM s_storehouse_view;

4.3.4商品表的视图

CREATE VIEW s_goods_view AS SELECT goods_name,goods_price FROM s_goods;

SELECT * FROM s_goods_view;

4.3.5商品类型的视图

CREATE VIEW s_goodstype_view AS SELECT type_name,content FROM s_goodstype;

SELECT * FROM s_goodstype_view;

4.3.6供应商表的视图

CREATE VIEW s_supplier_view AS SELECT supplier_name,supplier_address FROM s_supplier;

SELECT * FROM s_supplier_view;

4.使用SQL语句自定义完成增删改查操作

4.4.1进行表内容的增加

#在员工表员工id后面再添加一列任职仓库

ALTER TABLE s_employee ADD COLUMN storehouse_id VARCHAR(100)

NULL

AFTER employee_id;

4.4.2进行表内容的删除

#删除id=1的商品

DELETE FROM s_goods

WHERE goods_id = 1;

4.4.3进行表内容的修改

#将洁柔抽纸的价格修改为九折后的价格

UPDATE s_stock SET goods_price=ROUND(goods_price*0.9,4)WHERE goods_name='洁柔抽纸';

#把丹姿护发素的出库数量修改为3

UPDATE s_stock SET delivery_num=3 WHERE goods_name='丹姿护发素';

4.4.4进行表的查找

#显示各商品的出库数量,按出库数量有多到少排列

#ORDER BY

SELECT s.goods_name,SUM(s.delivery_num) AS num

FROM s_stock AS s

GROUP BY s.goods_id

ORDER BY num DESC;

五、总结

Guess you like

Origin blog.csdn.net/yh1009/article/details/130857542