【问题标题】:Database model for car-service [closed]汽车服务的数据库模型
【发布时间】:2018-10-04 16:51:18
【问题描述】:

我正在从事一个汽车服务项目(凹痕、油漆)。在这个应用程序中,用户将选择他们的位置,然后选择汽车品牌、型号和燃料类型。之后,他将看到一个服务列表并将它们添加到购物车。然后他可以订购服务。 那么,如何为此设计数据库。我对如何根据不同的汽车和位置改变价格的存储服务感到困惑。

【问题讨论】:

  • 你的问题太宽泛了。试着把它分解成更小的部分。
  • @The impaler,我的主要问题是为不同的汽车和不同的位置存储玻璃维修、凹痕、油漆等服务。因为不同汽车的服务价格不同。那么如何为此设计表格

标签: mysql sql database


【解决方案1】:

也许像这样的表格可以帮助您模拟价格变化:

create table service (
  id int primary key not null,
  name varchar(50)
);

create table car_type (
  id int primary key not null,
  name varchar(50)
);

create table location (
  id int primary key not null,
  name varchar(50)
);

create table service_price (
  service_id int not null,
  car_type_id int not null,
  location_id int not null,
  price numeric(12,2) not null,
  constraint fk1 foreign key service_id references service (id),
  constraint fk2 foreign key car_type_id references car_type (id),
  constraint fk3 foreign key location_id references location (id)
);  

这样,价格将按服务、汽车类型和位置单独存储。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-09
    • 1970-01-01
    相关资源
    最近更新 更多