Home Database Mysql Tutorial 网上商城不同类别产品数据库的设计思路

网上商城不同类别产品数据库的设计思路

Jun 07, 2016 pm 03:48 PM
different product Ideas database category online store design

问题的提出: 网上商城对产品进行了很多分类,不同的分类产品又有不同的属性,比如,电脑的属性有:CUP,内存, 主板,硬盘等等,服装的属性有:布料,尺寸,颜色等等,那么产品表以及产品分类表应该如何设计才能满足 不同类型产品的区别呢? 解决方案: 产

问题的提出:网上商城对产品进行了很多分类,不同的分类产品又有不同的属性,比如,电脑的属性有:CUP,内存,
                  主板,硬盘等等,服装的属性有:布料,尺寸,颜色等等,那么产品表以及产品分类表应该如何设计才能满足

                  不同类型产品的区别呢?

解决方案:
     产品分类表的设计
     第一种设计思路:使用树形结构,递归的形式,可以对产品进行N种     分类,只要你喜欢,树形结构在数据库的设计中
                             经常用到,比如功能菜单表等以下是一个简单的产品分类表。


            
网上商城不同类别产品数据库的设计思路

 

                          说明:上级类别ID为该表的外键,并关联到本级类别ID,这样就可以对产进行N中分类了,这种设计
                                   思想十分灵活,是无限分类中最常用到的。

第二种设计思路:定义N个类别表,并对他们进行关联,如图:

 

          网上商城不同类别产品数据库的设计思路
 

 

                       说明:这种设计在项目中没有人会使用它,因为产品的分类是不固定的,很难在数据库设计的时候确定
                                类别 表的个数,很不灵活。

2、产品表的设计
      第一种设计思路:直接在产品表预留N个字段,用到的时候直接插入数据,如图

                  
网上商城不同类别产品数据库的设计思路
                  可行性:会产生很多字段的冗余,并且不知道到底需要多少个字段,数据类型也不能确定,可行性比较低,但
                              是这种设计也有它的优点,就是表的数量少,其他的优点我实在找不出来了,所以,在项目中这种设
                              计思想也不会用到。

第二种设计思路: 在提及这种设计思路前,首先得了解数据表可以分为两种结构,一种是横表,也就是我们经常用到
                               的表结构,另外一种是纵表,这种结构平时我们用到的表少,所以我也是今天通过请教别人才知
                               有这种表结构的。
     什么是纵表,它有哪些优点和缺点呢?通过两张图片对比来了解或许会更清楚

横表的结构:

     
     网上商城不同类别产品数据库的设计思路
     纵表的结构:

     
     网上商城不同类别产品数据库的设计思路

 

                可以看出横表的优点是很直观,它是根据现行业务逻辑定制,设计简单,易操作,缺点是当业务逻辑发生拓展
          时,大多情况下要更改表的结构。纵表的数据让人看着感觉很乱,而且字段的数据出现很大的冗余,但是纵表的还
         是有很多好处的,它比较灵活,当业务系统发生拓展时可以很好的适应, 知道了这些,那么我们可以进行产品表的
         设计了,在这种设计思想中,需要三个表,一个为产品表,用来存产品的公共属性,另外一个是产品分类表,最后一
         个表很关键,用来存不同类别产品的不同属性,采用的是纵表的结构,如图:   


        
网上商城不同类别产品数据库的设计思路
 
                 说明:通过产品拓展属性表,用户在页面就可以动态的某一类产品添加属性,添加好以后,就采用动态SQL提
           取该类商品的属性生成相应的产品类别属性横表,用来保存产品的属性值
,比如:用户在界面为电脑类ID为
           COMP这一类产品中添加了CUP、内存EMS这两个属性,那么将会动态的提取这两个属性,生成横表T_COMP,
           如图:
 

         
网上商城不同类别产品数据库的设计思路
 
        具体怎么实现,有了设计思路,剩下的就是很死的东西了,或许这种设计不是最好的,但是也是我找了好久资料,也
 向别人请教以后才弄明白这个流程的…… 

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Retro trend! HMD and Heineken jointly launch flip phone: transparent shell design Retro trend! HMD and Heineken jointly launch flip phone: transparent shell design Apr 17, 2024 pm 06:50 PM

According to news on April 17, HMD teamed up with the well-known beer brand Heineken and the creative company Bodega to launch a unique flip phone - The Boring Phone. This phone is not only full of innovation in design, but also returns to nature in terms of functionality, aiming to lead people back to real interpersonal interactions and enjoy the pure time of drinking with friends. Boring mobile phone adopts a unique transparent flip design, showing a simple yet elegant aesthetic. It is equipped with a 2.8-inch QVGA display inside and a 1.77-inch display outside, providing users with a basic visual interaction experience. In terms of photography, although it is only equipped with a 30-megapixel camera, it is enough to handle simple daily tasks.

ZTE 5G portable Wi-Fi U50S goes on sale for NT$899 at first launch: top speed 500Mbps ZTE 5G portable Wi-Fi U50S goes on sale for NT$899 at first launch: top speed 500Mbps Apr 26, 2024 pm 03:46 PM

According to news on April 26, ZTE’s 5G portable Wi-Fi U50S is now officially on sale, starting at 899 yuan. In terms of appearance design, ZTE U50S Portable Wi-Fi is simple and stylish, easy to hold and pack. Its size is 159/73/18mm and is easy to carry, allowing you to enjoy 5G high-speed network anytime and anywhere, achieving an unimpeded mobile office and entertainment experience. ZTE 5G portable Wi-Fi U50S supports the advanced Wi-Fi 6 protocol with a peak rate of up to 1800Mbps. It relies on the Snapdragon X55 high-performance 5G platform to provide users with an extremely fast network experience. Not only does it support the 5G dual-mode SA+NSA network environment and Sub-6GHz frequency band, the measured network speed can even reach an astonishing 500Mbps, which is easily satisfactory.

Honor Magic V3 debuts AI defocus eye protection technology: effectively alleviates the development of myopia Honor Magic V3 debuts AI defocus eye protection technology: effectively alleviates the development of myopia Jul 18, 2024 am 09:27 AM

According to news on July 12, the Honor Magic V3 series was officially released today, equipped with the new Honor Vision Soothing Oasis eye protection screen. While the screen itself has high specifications and high quality, it also pioneered the introduction of AI active eye protection technology. It is reported that the traditional way to alleviate myopia is "myopia glasses". The power of myopia glasses is evenly distributed to ensure that the central area of ​​​​sight is imaged on the retina, but the peripheral area is imaged behind the retina. The retina senses that the image is behind, promoting the eye axis direction. grow later, thereby deepening the degree. At present, one of the main ways to alleviate the development of myopia is the "defocus lens". The central area has a normal power, and the peripheral area is adjusted through optical design partitions, so that the image in the peripheral area falls in front of the retina.

How does Hibernate implement polymorphic mapping? How does Hibernate implement polymorphic mapping? Apr 17, 2024 pm 12:09 PM

Hibernate polymorphic mapping can map inherited classes to the database and provides the following mapping types: joined-subclass: Create a separate table for the subclass, including all columns of the parent class. table-per-class: Create a separate table for subclasses, containing only subclass-specific columns. union-subclass: similar to joined-subclass, but the parent class table unions all subclass columns.

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos Jul 18, 2024 am 05:48 AM

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

New stacking process! Xiaomi MIX Fold 4 is equipped with Jinshajiang 'three-dimensional special-shaped' battery for the first time New stacking process! Xiaomi MIX Fold 4 is equipped with Jinshajiang 'three-dimensional special-shaped' battery for the first time Jul 20, 2024 am 03:20 AM

According to news on July 19, Xiaomi MIX Fold 4, the first flagship folding new phone, was officially released tonight and is equipped with a "three-dimensional special-shaped battery" for the first time. According to reports, Xiaomi MIX Fold4 has achieved a major breakthrough in battery technology and designed an innovative "three-dimensional special-shaped battery" specifically for folding screens. Traditional folding screen devices mostly use conventional square batteries, which have low space utilization efficiency. In order to solve this problem, Xiaomi did not use the common winding battery cells, but developed a new lamination process to create a new form of battery, which greatly improved the space utilization. Battery Technology Innovation In order to accurately alternately stack positive and negative electrode sheets and ensure the safe embedding of lithium ions, Xiaomi has developed a new ultrasonic welding machine and lamination machine to improve welding and cutting accuracy.

Honor X60i mobile phone is on sale starting from 1,399 yuan: visual quadrilateral OLED direct screen Honor X60i mobile phone is on sale starting from 1,399 yuan: visual quadrilateral OLED direct screen Jul 29, 2024 pm 08:25 PM

According to news on July 29, the Honor X60i mobile phone is officially on sale today, starting at 1,399 yuan. In terms of design, the Honor X60i mobile phone adopts a straight screen design with a hole in the center and almost unbounded ultra-narrow borders on all four sides, which greatly broadens the field of view. Honor X60i parameters Display: 6.7-inch high-definition display Battery: 5000mAh large-capacity battery Processor: Dimensity 6080 processor (TSMC 6nm, 2x2.4G A76+6×2G A55) System: MagicOS8.0 system Other features: 5G signal enhancement, smart capsule, under-screen fingerprint, dual MIC, noise reduction, knowledge Q&A, photography capabilities: rear dual camera system: 50 million pixels main camera, 2 million pixels auxiliary lens, front selfie lens: 8 million pixels, price: 8GB

The 2024 Apple iPad Pro/Air does not support the second-generation Apple Pencil: you can buy a new one if you need it The 2024 Apple iPad Pro/Air does not support the second-generation Apple Pencil: you can buy a new one if you need it May 08, 2024 pm 04:07 PM

According to news on May 8, Apple’s new iPad Pro/Air tablets have been released. According to Apple’s official website, the new iPad Pro and iPad Air no longer support the second-generation Apple Pencil released in 2018, but only support Apple Pencil Pro and Apple Pencil (USB- C). Apple Pencil (USB-C) will be released in November 2023. This stylus maintains the same pixel-level accuracy, low latency, and tilt-angle sensing features as the first and second-generation Apple Pencil, while eliminating pressure sensitivity. function and does not support wireless charging. Its price is 649 yuan. And the newly released ApplePe

See all articles