关于数据库的变更设计的思考随笔
11数据库中表结构的变更总是一件让人感觉不舒服的事情。 在新增加字段时,如何对以前的操作不产生影响或者将影响降至最低呢? 一种方法:直接在表上增加一个字段,给该字段设置一个默认值,该默认值用于标记以前的数据,然后用新的值来标记以后的数据。 如果
11数据库中表结构的变更总是一件让人感觉不舒服的事情。
在新增加字段时,如何对以前的操作不产生影响或者将影响降至最低呢?
一种方法:直接在表上增加一个字段,给该字段设置一个默认值,该默认值用于标记以前的数据,然后用新的值来标记以后的数据。
如果说是标记的话,那么为什么不在设计的时候就专门建立一个字段,来作为数据的版本标识呢?
但是问题好像没有这么简单,比如:在His系统的设计中,有关科室人员的设计,在最基础的版本中,只需要有科室人员的姓名,登陆密码,编号,所属科室等信息就够了。但是如果医院领导要求在更大的范围内对医院进行信息话的管理,那么在科室人员数据的设计上,就要再增加新的内容,比如:出生日期,家庭住址,学历,职称,是否是党员等等,这些数据该如何处理呢?是重新设计数据库吗?
在设计数据库的时候,里面的数据流程也是数据的生长轨迹,可否专门对生长轨迹进行处理来简化数据流程的处理呢?
用流程数据来代替标记数据。
如:chufang_mx表中,bz为标记该处方的状态:1-划价,2-收费,3-取药,4-退药,5-退费审核,6-退费。
用流程数据表示:建立一个用于维护处方数据流程的表chufang_lc(chufangid, hj,sf,qy,ty,tfsh,tf),每完成对该处方的处理,就将对应的流程数据置为1。作为流程,只要判断当前流程是否处理及上一流程是否处理,就可以知道是否可以处理当前流程。这样就可以轻松维护数据流程了(我现在实在厌烦在数据库的设计文档上标记各种状态值的含义,还有就是判断当前的处理是否满足流程要求,有没有跨过流程处理的可能性。)
对于以上设计,按照数据库的设计原则,可以设计为两个表:流程记录表(流程记录id,流程描述),流程记录明细表(流程记录id,流程记录序号,流程步骤描述,流程执行标记(布尔值)),这两个表中的数据和业务数据对应。
再加上两个流程维护表:流程信息表(流程id,流程描述),流程信息明细表(流程id,流程序号,流程步骤描述)
对于流程维护表,其信息也可以将其绑定于处理这些数据对象上,因为同一个数据集,其处理对象不同,就意味着其处理流程不同,并且可以为处理对象的各个方法标上流程中的处理序号,这样就可以轻松判断处理对象上的某个方法当前是否可以处理他对应的数据了。
对于流程,为什么不直接在设计某个实体的时候,直接给他加上流程编码呢?比如给处方表加上lc,那么定义:lc=1时,处方划价;lc=2时,处方收费。这样也可以体现流程信息。
经过几天这几天的思考,发现同一个数据,在系统流程的不同环节,对其的描述不一样.这就有一点像在现实生活中,对同一个人,处于不同环境的其它人对它的描述肯定不一样。而对于这个描述,其特征应该是复合的,即对于这个人的描述是综合了这个人的一个或者多个特征的组合来完成的。比如说:老师说小明是一个好学生,那么老师说这句话的时候,老师的大脑里一定出现了小明平时的几个特征:上课专心听讲,积极发言,认真完成作业等等。而小明的妈妈说小明是一个乖儿子,妈妈在说这句话的时候,大脑里出现的是小明的其它特征:有孝心,成绩好,能够体谅妈妈等等。这就说明,一个对象在对另一个对象进行处理时,是综合了它的特征的。那么就是说,对象应该有一个它的特征列表,这个特征列表是这个对象在处理中的前提。
呵呵,这个好像有点像游戏设计了。其实在处理商业逻辑中,也应该是这个道理。把那些分散的标记管理起来,然后对商业的逻辑对象进行处理。
根据以上思路,必须在系统中注册各个对象的描述,这些描述是系统数据处理的依据,它对了对象的特征集,而对象的每一个特征都有相应的处理方法。

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

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.

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.

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.

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.

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

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

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

According to news on May 13, vivoX100s was officially released tonight. In addition to excellent images, the new phone also performs very well in terms of signal. According to vivo’s official introduction, vivoX100s uses an innovative universal signal amplification system, which is equipped with up to 21 antennas. This design has been re-optimized based on the direct screen to balance many signal requirements such as 5G, 4G, Wi-Fi, GPS, and NFC. This makes vivoX100s the mobile phone with the strongest signal reception capability in vivo’s history. The new phone also uses a unique 360° surround design, with antennas distributed around the body. This design not only enhances the signal strength, but also optimizes various daily holding postures to avoid problems caused by improper holding methods.
