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.

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

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!