订单管理系统E-R图
创建表
根据简单的ER图创建六个表
1、用户表
用户id、用户姓名、用户密码、用户权限,手机号码、地址- CREATETABLEUSER(
- id INTPRIMARYKEY,
- userName VARCHAR(50),
- userPassword VARCHAR(50),
- roleID INT,
- phone VARCHAR(11),
- address VARCHAR(50));
复制代码 2、商品表
商品id、商品名称、价格、计量单位、库存、商品信息(商品介绍)- createtable product{
- productID intprimarykey,
- productName VARCHAR(50),
- price float,
- unit VARCHAR(50),
- inventory int,
- productInfo VARCHAR(100)
- }
复制代码 3、供给商
供给商id、供给商名称、供给商地址、手机- createtable supplier(
- supplierID INTPRIMARYKEY,
- supplierName VARCHAR(50),
- phone VARCHAR(11),
- address VARCHAR(50));
复制代码 4、订单表
用户id 、商品id 、购置数量、下单日期- CREATETABLE orders(
- userID INT,
- productID INT,
- quantity INT,
- createDate DATE,PRIMARYKEY(userID,productID));
复制代码 5、采购表
供给商id、商品id、采购数量、采购日期- createtable purchase(
- supplierID INT,
- productID INT,
- quantity INT,
- createDate DATE,PRIMARYKEY(supplierID,productID));
复制代码 6、权限表
角色id、角色名称、角色权限说明- CREATETABLE role(
- roleId INTPRIMARYKEY,
- roleName VARCHAR(50),
- roleInfo VARCHAR(100));
复制代码 创建实体类
必需有一个无参数构造属性必需私有化必需有对应的get/set方法
一般用来和数据库字段作映射
以用userInfo 表为例
在实体类包里创建UserInfo 类- package com.tin.pojo;publicclassUserInfo{privateint userID;private String userName;private String userPassword;privateint roleID;private String phone;private String address;//通过结合查询获取用户的角色名称private String userRoleName;publicUserInfo(){}publicintgetUserID(){return userID;}public String getUserName(){return userName;}public String getUserPassword(){return userPassword;}publicintgetRoleID(){return roleID;}public String getPhone(){return phone;}public String getAddress(){return address;}publicvoidsetUserID(int userID){this.userID = userID;}publicvoidsetUserName(String userName){this.userName = userName;}publicvoidsetUserPassword(String userPassword){this.userPassword = userPassword;}publicvoidsetRoleID(int roleID){this.roleID = roleID;}publicvoidsetPhone(String phone){this.phone = phone;}publicvoidsetAddress(String address){this.address = address;}}
复制代码 |