当前位置:   article > 正文

模仿滴滴打车的数据库设计、实体类映射关系配置、语句增删改查(1)_滴滴打车表设计

滴滴打车表设计

1.数据库设计


1.用户表:用户Id(主键),登录名,登录密码,手机号,用户状态(0存在,1注销(数据不可用))

(增,删,改(修改信息,注销),查(查所有,按照编号、手机号进行查询))


2.司机表:司机id(主键),姓名,身份证号,手机号,状态(0等待接单,1注销,2未上班,3已接单)服务等级(1-5级别,根据级别分派订单) (number(1,1)),接单数量


3.管理员:管理员id,管理员密码,管理员权限(0管理用户,1管理司机,车辆,2管理订单和退款,评论等)


4.车辆信息表:车辆id(主键),司机id(外键),车牌号,车型,颜色,状态(0正常形式,1注销,2处理中),类别id(外键)


5.业务类别:类别id(主键),类别名称


6.订单表:订单id(主键),车辆id(外键),用户id(外键),订单创建时间,订单结束时间,起始位置,目的地,订单状态(0进行中,1取消,2 结束,3处理中),订单金额


7.退款记录表:记录表id,订单id,退款原因,退款开始时间,退款结束时间,记录表状态(0退款中,1退款成功,2退款失败),退款金额


8.评论表:评论表id,订单Id,评论时间,评论内容,回复内容,打分


关系:
1.订单表和用户表、车辆信息表是一对一
2.车辆信息表和司机表是多对一的关系
3.业务类别和车辆表是一对多的关系
4.退款记录表和订单表是一对一的关系

5.评论表和订单是多对一的关系

  1. --用户表--
  2. create table users
  3. (
  4. user_id number(4) not null,
  5. user_name nvarchar2(10) not null,
  6. user_password nvarchar2(20) not null,
  7. user_phone nvarchar2(22) not null,
  8. user_state nvarchar2(2) not null,
  9. constraint PK_STUDENT primary key (user_id)
  10. );
  11. --司机表--
  12. create table driver
  13. (
  14. driver_id number(4) not null,
  15. driver_name nvarchar2(10) not null,
  16. driver_idcard nvarchar2(20) not null,
  17. driver_phone nvarchar2(11) not null,
  18. driver_state nvarchar2(2) not null,
  19. driver_service number(4) not null,
  20. driver_amount nvarchar2(10) not null,
  21. constraint PK_DRIVER primary key (driver_id)
  22. );
  23. --管理员表--
  24. create table admin
  25. (
  26. admin_id number(4) not null,
  27. admin_name nvarchar2(10) not null,
  28. admin_password nvarchar2(20) not null,
  29. admin_limits nvarchar2(2) not null,
  30. constraint PK_ADMIN primary key (admin_id)
  31. );
  32. --汽车信息表--
  33. create table car
  34. (
  35. car_id number(4) not null,
  36. car_number nvarchar2(10) not null,
  37. car_type nvarchar2(20) not null,
  38. car_color nvarchar2(10) not null,
  39. car_state nvarchar2(2) not null,
  40. driver_id number(4) not null,
  41. sort_id number(4) not null,
  42. constraint PK_CAR primary key (car_id)
  43. );
  44. --业务类别表--
  45. create table sort
  46. (
  47. sort_id number(4) not null,
  48. sort_name nvarchar2(6) not null,
  49. constraint PK_SORT primary key (sort_id)
  50. );
  51. --订单表--
  52. create table orderform
  53. (
  54. orderform_id number(4) not null,
  55. orderform_createdtime nvarchar2(30) not null,
  56. orderform_finishedtime nvarchar2(30) not null,
  57. orderform_startaddress nvarchar2(200) not null,
  58. orderform_endaddress nvarchar2(200) not null,
  59. orderform_state nvarchar2(2) not null,
  60. orderform_money number(5,2) not null,
  61. car_id number(4) not null,
  62. user_id number(4) not null,
  63. constraint PK_ORDER primary key (orderform_id)
  64. );
  65. --退款记录表--退款记录表:记录表id,订单id,退款原因,
  66. --退款开始时间,退款结束时间,记录表状态(0退款中,1退款成功,2退款失败),退款金额
  67. create table refund
  68. (
  69. refund_id number(4) not null,
  70. refund_reason nvarchar2(100) not null,
  71. refund_startedtime nvarchar2(50) not null,
  72. refund_finishedtime nvarchar2(50) not null,
  73. refund_state nvarchar2(20) not null,
  74. refund_money number(8,2) not null,
  75. orderform_id number(4) not null,
  76. constraint PK_REFUND primary key (refund_id)
  77. );
  78. --评论表:评论表id,订单Id,评论时间,评论内容,回复内容,打分
  79. create table comments(
  80. comments_id number(4) not null,
  81. comments_time nvarchar2(100) not null,
  82. comments_context nvarchar2(1000) ,
  83. comments_grade number(4,2) not null,
  84. comments_reply nvarchar2(100),
  85. orderform_id number(4) not null,
  86. constraint PK_COMMENTS primary key (comments_id)
  87. );

2.实体类编写及映射文件配置

  1. package com.vo;
  2. public class Car {
  3. private int car_id;
  4. private String car_number;
  5. private String car_type;
  6. private String car_color;
  7. private String car_state;
  8. private Driver driver;
  9. private Sort sort;
  10. public Car() {
  11. super();
  12. // TODO Auto-generated constructor stub
  13. }
  14. public Car(int car_id, String car_number, String car_type, String car_color, String car_state) {
  15. super();
  16. this.car_id = car_id;
  17. this.car_number = car_number;
  18. this.car_type = car_type;
  19. this.car_color = car_color;
  20. this.car_state = car_state;
  21. }
  22. public Car(int car_id, String car_number, String car_type, String car_color, String car_state, Driver driver,
  23. Sort sort) {
  24. super();
  25. this.car_id = car_id;
  26. this.car_number = car_number;
  27. this.car_type = car_type;
  28. this.car_color = car_color;
  29. this.car_state = car_state;
  30. this.driver = driver;
  31. this.sort = sort;
  32. }
  33. // public Car(int car_id, String car_number, String car_type, String
  34. // car_color, String car_state) {
  35. // super();
  36. // this.car_id = car_id;
  37. // this.car_number = car_number;
  38. // this.car_type = car_type;
  39. // this.car_color = car_color;
  40. // this.car_state = car_state;
  41. // }
  42. public int getCar_id() {
  43. return car_id;
  44. }
  45. public void setCar_id(int car_id) {
  46. this.car_id = car_id;
  47. }
  48. public String getCar_number() {
  49. return car_number;
  50. }
  51. public void setCar_number(String car_number) {
  52. this.car_number = car_number;
  53. }
  54. public String getCar_type() {
  55. return car_type;
  56. }
  57. public void setCar_type(String car_type) {
  58. this.car_type = car_type;
  59. }
  60. public String getCar_color() {
  61. return car_color;
  62. }
  63. public void setCar_color(String car_color) {
  64. this.car_color = car_color;
  65. }
  66. public String getCar_state() {
  67. return car_state;
  68. }
  69. public void setCar_state(String car_state) {
  70. this.car_state = car_state;
  71. }
  72. public String getCars_state() {
  73. return car_state;
  74. }
  75. public void setCars_state(String car_state) {
  76. this.car_state = car_state;
  77. }
  78. public Driver getDriver() {
  79. return driver;
  80. }
  81. public void setDriver(Driver driver
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/123561
推荐阅读
相关标签
  

闽ICP备14008679号