Home Database Mysql Tutorial 机房收费系统数据库设计

机房收费系统数据库设计

Jun 07, 2016 pm 03:57 PM
study database write design

之前,学习编写机房收费系统的文档时,曾写过 机房收费系统数据库概念设计模型ER图 这篇文章,现在到了机房收费系统个人版重构阶段,需要再次进行数据库的设计。可以说,之前的数据库的概念设计给我现在的设计奠定了一定的基础,但是仍然发现自己的设计中有

之前,学习编写机房收费系统的文档时,曾写过 机房收费系统数据库概念设计模型——ER图 这篇文章,现在到了机房收费系统个人版重构阶段,需要再次进行数据库的设计。可以说,之前的数据库的概念设计给我现在的设计奠定了一定的基础,但是仍然发现自己的设计中有许多不合理并且需要改进的地方。

在这次的数据库设计当中,学习了一些数据库的命名规范,重温了经典的三范式(属性原子化,避免局部依赖,避免传递依赖)。但是发现,在需求面前,一些分属两张表的字段,为了方便,还是得放到一张表中,不得不破坏三范式。

现在将自己设计的数据库分享如下:(因为自己还没真正进行机房的重构,不知道在实际应用中,这些表是否合理,还请大家提宝贵意见。微笑

数据库名ComputerRoomChargeSystem

学生信息表(T_StudentInfo)

名称

意义

类型

studentID

学号(主键)

Char(10)

studentName

姓名

Char(10)

sex

性别

Char(2)

department

系别

Char(20)

grade

年级

Char(10)

class

班级

Char(10)

这里,我将学生的信息和卡的信息分成两张表,首先,考虑到它们本身就属于不同的实体,其次,想到如果卡不用 了,就得把卡的信息删除,那么学生信息也得跟着删除(不过,后来想到,卡的信息可以不用删除,可通过标记其状态为“未使用”来区分)。最后,感觉把这么多字段放在一个表中,它看起来实在是太“臃肿”了。

用户信息表(T_UserInfo)

名称

意义

类型

UserID

用户名(主键)

Char(10)

realName

真实姓名

Char(10)

userLevel

用户级别

Char(8)

userPassword

用户密码

Char(10)

accountHolder

开户人

Char(10)

卡信息(T_CardInfo)

名称

意义

类型

cardID

卡号(主键)

Char(10)

studentID

学号(外键)

Char(10)

account

余额

Decimal(10,4)

usageState

使用状态

Char(6)

cardType

卡类型

Char(8)

registrationDate

注册日期

Date

registrationTime

注册时间

Time(0)

UserID

用户名

Char(10)

checkStatus

结账状态

Bit(1)

这里,使用状态用来标记该卡是使用,还是未使用(已退卡)。卡类型来标记是固定用户还是临时用户。

账单(T_AccountSheet)

名称

意义

类型

checkID

结账编号(主键)

Decimal(18,0)

lastCardMoney

上期充值卡金额

Decimal(18,4)

currentChargeMoney

本期充值金额

Decimal(18,4)

currentReturnMoney

本期退卡金额

Decimal(18,4)

currentConsumeMoney

本期消费金额

Decimal(18,4)

currentCardMoney

本期充值卡金额

Decimal(18,4)

checkDate

结账日期

Date

checkTime

结账时间

Time(0)

userID

用户名

Char(10)

账单,我为其设置了一个结账编号,作为主键,我想在真正建表时,可以按照结账编号从大到小排列,因为在打印账单或是日结账, 周结账都是结最近的账单吧。

本期充值卡金额=上期充值卡金额+本期充值金额-本期消费金额-本期退卡金额

充值记录表(T_ChargeRecord)

名称

意义

类型

cardID

卡号(外键)

Char(10)

chargeDate

充值日期

Date

chargeTime

充值时间

Time(0)

chargeMoney

充值金额

Decimal(10,4)

checkStatus

结账状态

Bit(1)

userID

用户名

Char(10)

退卡记录表(T_ReturnRecord)

名称

意义

类型

cardID

卡号(外键)

Char(10)

returnDate

退卡日期

Date

returnTime

退卡时间

Time(0)

account

退卡金额

Decimal(10,4)

checkStatus

结账状态

Bit(1)

userID

用户名

Char(10)

上下机记录表(T_OnOffLineRecord)

名称

意义

类型

cardID

卡号(外键)

Char(10)

onDate

上机日期

Date

onTime

上机时间

Time(0)

offDate

下机日期

Date

offTime

下机时间

Time(0)

offWay

下机方式

Char(8)

consumeMoney

消费金额

Decimal(10,4)

userID

用户名

Char(10)

checkStatus

结账状态

Char(6)

onFlag

正在上机标志

Bit(1)

在这个表中,我增加了结账状态这个字段,因为想到结账时,除了会结购卡数,充值金额,退卡金额,还要结消费金额。

基本数据表(T_BasicData)

名称

意义

类型

fixedPerCharge

固定每小时费用

Decimal(10,4)

temporaryPerCharge

临时每小时费用

Decimal(10,4)

increasingUnitTime

递增单位时间

SmallInt

leastTime

至少上机时间

SmallInt

prepareTime

准备时间

SmallInt

minMoney

最少金额

Decimal(10,4)

操作员工作记录(T_WorkLog)

名称

意义

类型

UserID

用户名(外键)

Char(10)

LoginDate

登录日期

Date

LoginTime

登录时间

Time(0)

ExitDate

注销日期

Date

ExitTime

注销时间

Time(0)

onFlag

正在上机标志

Bit(1)

computerID

机器名

Varchar(10)

小结:自己感觉数据库设计是件很有意思的事情,在画机房重构版的类图时,感觉还得先从数据库设计入手,所以数据库设计还是很重要的啊!
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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks 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)

Hot Topics

Java Tutorial
1666
14
PHP Tutorial
1273
29
C# Tutorial
1253
24
Vivo's phone with the strongest signal! vivo X100s is equipped with a universal signal amplification system: 21 antennas, 360° surround design Vivo's phone with the strongest signal! vivo X100s is equipped with a universal signal amplification system: 21 antennas, 360° surround design Jun 03, 2024 pm 08:41 PM

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.

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.

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

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

How to handle database connection errors in PHP How to handle database connection errors in PHP Jun 05, 2024 pm 02:16 PM

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

Detailed tutorial on establishing a database connection using MySQLi in PHP Detailed tutorial on establishing a database connection using MySQLi in PHP Jun 04, 2024 pm 01:42 PM

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

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.

Xiaomi's 100-yuan phone Redmi 14C design specifications revealed, will be released on August 31 Xiaomi's 100-yuan phone Redmi 14C design specifications revealed, will be released on August 31 Aug 23, 2024 pm 09:31 PM

Xiaomi's Redmi brand is gearing up to add another budget phone to its portfolio - the Redmi 14C. The device is confirmed to be released in Vietnam on August 31st. However, ahead of the launch, the phone's specifications have been revealed via a Vietnamese retailer. Redmi14CR Redmi often brings new designs in new series, and Redmi14C is no exception. The phone has a large circular camera module on the back, which is completely different from the design of its predecessor. The blue color version even uses a gradient design to make it look more high-end. However, Redmi14C is actually an economical mobile phone. The camera module consists of four rings; one houses the main 50-megapixel sensor, and another may house the camera for depth information.

See all articles