数据库设计的困惑,该怎么解决
数据库设计的困惑
情况是这样的,我以前做网站的时候遇到像“推荐”,“置顶”啊之类的,都是在表里加一个字段如“IsTop”或是"IsDelete"等,用BOOL型。可是最近来到新公司,公司的领导不是这么做的。如:“IsTop”表示是否删除,他就用建一个news_delete表,里面的记录就是己经"IsTop"的ID值。
这么做好像也不错,用起也很方便。要增加别的类似别的,不用在修改原有的表了。请问在数据库设计方面的高手们,如何是好。
------解决方案--------------------
感觉都可以,如果觉得数据结构复杂,就按照第二种来设计,拆分开来。
------解决方案--------------------
要学会宽容
对于你的描述,没有一定的规则
附加的属性与基础数据有紧密的联系
很显然,你的方案要优于分表方案
------解决方案--------------------
自定义字段的两种做法,一种是往本表加字段,一种是建一自定义字段表存值。个人认为各有千秋吧,后者语句稍微复杂些,也不好弄索引,搜索不方便,需要join操作,数据增多,可能会有效率问题,不过胜在扩展方便,前者简单暴力,方便设置索引进行搜索,不过不好扩展业务,最好两种方案都保留,具体问题具体做法。
------解决方案--------------------
------解决方案--------------------
------解决方案--------------------
问题解决了 也该把贴结了。看看你的结贴率。0% 发帖:7 正常结贴:0

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The meaning of JOIN is just like the English word "join". It joins two tables and can be roughly divided into inner join, outer join, right join, left join and natural join. First create two tables, the following is used as an example CREATETABLEt_blog(idINTPRIMARYKEYAUTO_INCREMENT,titleVARCHAR(50),typeIdINT);SELECT*FROMt_blog;+----+------+--------+| id|title|typeId|+----+-------+--------+|1|aaa|1||2|bbb|2||3|ccc|3|

Join type leftjoin uses the left table as the driving table and the left table as the basis of the result set. The data from the right table is connected to the result set. rightjoin uses the right table as the driving table and the right table as the basis of the result set to connect the left table. The data is added to the result set innerjoin. The result set takes the intersection of the two tables fulljoin. The result set takes the union of the two tables. MySQL does not have a fulljoin. The difference between union and unionall is that union will deduplicate the crossjoin Cartesian product. If the where condition is not used, the result set will be the product and of the two associated table rows. The difference is that when crossjoin creates the result set, it will be passed according to the on condition.

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

Compared with join query and multiple queries, which one is more efficient, MySQL multi-table related query or multiple single-table query? When the amount of data is not large enough, there is no problem using join, but it is usually done on the service layer. First: the computing resources of a stand-alone database are very expensive, and the database needs to serve both writing and reading at the same time, which requires CPU consumption. In order to make the database The throughput becomes higher, and the business does not care about the delay gap of hundreds of microseconds to milliseconds. The business will put more calculations into the service layer. After all, computing resources can be easily expanded horizontally, and databases are difficult, so most The business will put pure computing operations into the service layer, and use the database as a kv system with transaction capabilities. This is a heavy business.

Introduction A's unique + AB's public B's unique + AB's public AB's public A's unique B's unique A's unique + B's unique + AB's public A's unique + B's unique Practice creating table department tables DROPTABLEIFEXISTS`dept`;CREATETABLE`dept`(`dept_id`int(11)NOTNULLAUTO_INCREMENT,`dept_name`varchar(30)DEFAULTNULL,`dept_number`int(11)DEFAULTNULL,PRIMARYKEY(`dept_id`))ENGINE =InnoDBAUT

Use MySQL's JOIN function to join tables. In MySQL, JOIN is a very common operation that allows us to join two or more tables based on the associated fields between them. This makes it easy to query and obtain relevant data from multiple tables, improving query efficiency and flexibility. This article will use code examples to demonstrate how to use MySQL's JOIN function to join tables. First create two sample tables: students and scores. The students table contains students

SimpleNested-LoopJoin Let's take a look at how mysql works when performing join operations. What are the common join methods? As shown in the figure, when we perform a connection operation, the table on the left is the driving table, and the table on the right is the driven table. SimpleNested-LoopJoin This connection operation is to take a record from the driving table and then match the records of the driven table one by one. If the condition If there is a match, the result is returned. Then the next record in the driver table is taken for matching until all the data in the driver table is matched. Because it is time-consuming to retrieve data from the driver table each time, MySQL does not use this algorithm to perform the connection operation BlockNested-LoopJ

In most web applications, database operations are the most basic and important part. As the most commonly used relational database management system at present, MySQL hosts countless websites and applications and is also facing increasing pressure on large-scale data processing and query access. In this context, performance optimization has become an important part of MySQL database management, and JOIN operation is a key point. JOIN connection is one of the most commonly used data query statements in MySQL. exist
