dongqiao0953 2017-07-12 10:04
浏览 60
已采纳

优化数据库设计中的表

I have 3 tables Product, Color and Category. Color and category table has just name field. So I need to optimize number of tables. Because For retrieving data for product, I need to get data from all of these tables. Instead of it, I just want something like single table. So Everything can be retrieve from Single table.

In short, Looking for way to adjust color and category name in product table with Dynamic Insert and update functionality.

Product Table

product_id | int
name       | varchar
description| text
category   | cat_id
color      | color_id
size       | size_id

Color Table

color_id   | int
color      | varchar  

Category Table

cat_id     | int
category   | varchar  

For retrieving data form Product table, I need to write JOIN, Because color and category have data for product table. and more Join query results more loading time. So need to optimize number of tables.

  • 写回答

1条回答 默认 最新

  • dongshi2141 2017-07-12 10:27
    关注

    Your current structure is good enough to hold product information with single color and category. Right now there is no need to optimize table structure. It look like perfect database structure for this.

    You can create view to avoid writing joins every time.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加
  • ¥15 用ns3仿真出5G核心网网元
  • ¥15 matlab答疑 关于海上风电的爬坡事件检测
  • ¥88 python部署量化回测异常问题
  • ¥15 在现有系统基础上增加功能