General steps and examples of designing a database
MySQL will definitely be used in current program development. MySQL is an open source small relational database management system. The developer is the Swedish MySQL AB company. MySQL is currently widely used in small and medium-sized websites on the Internet. Due to its small size, fast speed, low total cost of ownership, and especially the characteristics of open source, many small and medium-sized websites choose MySQL as their website database in order to reduce the total cost of website ownership. In this article, we will talk about the general steps and examples of designing a database.
1. General process of database design
1. Overview
Including course design topic selection, project background, purpose of writing the course design report, organization of the course design report, etc. .
2. Requirements analysis of course design tasks
2.1 Design tasks
2.2 Design requirements
2.3 Specification documents for requirement description
3. Conceptual structure design
3.1 Conceptual structure design tool (E-R model)
3.2XXX subsystem (partial)
3.2.1 Subsystem description
3.2.2 Points E-R Diagram
3.2.3 Description
3.3YYY Subsystem
3.3.1 Subsystem Description
3.3.2 Points E-R Figure
3.3.3 Description
……
3.X Overall E-R diagram
3.X.1 Integration of E-R diagram
3.X.2 Overall E-R diagram
4. Logical structure design
4.1 Relational data model
4.2 View design
4.3 Optimization
5. Database physical design and implementation
5.1 Introduction to the hardware and software environment of database application
5.2 Physical structure design
5.3 Index design
5.4 Establish database
5.5 Load database test data
6. Data operation requirements and implementation
6.1 Data query operation
6.2 Data update operation
6.3 Data maintenance operations
6.4 Others
7. Implementation of database application system
8. Design experience
9. References
2. Example: Student Course Selection Management System
In the teaching management system of colleges and universities, student course selection management is a very important functional module.
Requirement analysis:
The system should be able to manage the school’s teacher information, student information, professional information, all course information offered by the school, information on student elective courses, etc. The course selection system mainly meets the requirements of three types of users, namely system administrators, teachers and students of the Academic Affairs Office. The operation permissions and operation contents they have are different. The specific demand analysis is as follows:
System Administrator
Maintain students' basic personal information and realize the addition, deletion and modification of students' personal information.
Student information includes...
Maintain the basic personal information of teachers and realize the addition, deletion and modification of teachers' personal information.
Teacher information includes...
Maintain the basic personal information of the course and realize the addition, deletion and modification of the personal information of the course.
Course information includes...
Student users
Query and modify personal information.
Perform course selection operations
Students can view the course information they selected and the grade information of previously selected courses.
Teacher User
Query and modify personal information
After the course is over, register results
Teachers can check their teaching arrangements.
Database conceptual structure design:
The common tool for conceptual structure design is the ER diagram. Complete it in the following steps.
Data abstraction (abstract entities). Draw a diagram of the properties of each entity.
Design ER diagram. Find the entities and their connections and draw an ER diagram.
Merge the separate ER diagrams to generate a preliminary ER diagram.
Global ER diagram. Add the attributes of each entity to the preliminary ER diagram to eliminate possible local conflicts (including attribute conflicts, naming conflicts, and structural conflicts) to form a global ER diagram.
Database logical structure design:
First, convert the entities and relationships in the conceptual model ER diagram into a data model. In RDBMS, it is converted into a relational schema, and the attributes and attributes of the relational schema are determined. Master code.
The basic rules for converting ER diagrams to relational data models are as follows:
When an entity is converted into a relational schema, the attributes of the entity are the attributes of the relationship, and the keys of the entities are the keys of the relationship.
If the relationship between entities is 1:1, the relationship is not converted into a relationship model separately. The key of the other relationship model and the relationship need to be added to any one of the relationship models corresponding to the two entities. Attributes.
If the relationship between entities is 1:n, the relationship is not converted into a relationship schema separately. The key of the relationship schema corresponding to the 1-side entity and the attributes of the relationship need to be added to the relationship schema corresponding to the n-side entity. .
If the relationship between entities is m:n, the relationship is also converted into a relationship mode. Its attributes are the codes of the entity types at both ends plus the attributes of the relationship, and the keys of the relationship are the entities at both ends. combination of codes.
Secondly, perform the necessary merging of relationship patterns with the same primary key.
Relationship Optimization
Use the standardization theory as a guide to optimize the relational data model. Normalized to third normal form.
Physical design and implementation of database:
Mainly includes the following work:
Create database
Create basic tables, set constraints, and manage basic tables.
Create and manage indexes. (DBMS will automatically create an index for the primary key. Create an index to improve query efficiency.)
Create and manage views.
Enter data into the database.
Use SQL statements to perform operations such as data query, modification, and deletion. (You can think about how to manipulate the database first, and then implement it later)
Write stored procedures, triggers, etc., and pass debugging. (For example, create a trigger to automatically delete the course selection record in the course selection table when a student with a certain student number is deleted from the student table)
Database operation and maintenance:
Mainly includes the following content
Database backup and recovery
Database security and integrity control
Database performance monitoring, analysis and improvement
Access the database through The following statements manipulate data.
Add constraints to the gender and age fields of the student table.
Add an attribute column "Enrollment Time".
Modify the "professional" data type.
Add the constraint that the course name must have a unique value.
Create an index on the columns "student number" and "course number" in the course selection table.
Create an index on the "job number" and "course number" in the course selection table.
Assume that there are 4 departments in the student course selection system. In order to facilitate the teaching management personnel of each department to view the student information of the department, each department creates a student view.
Create a view that reflects students' course selection.
Students can check their course selection information by their student number or name.
Students can check their basic information through their student number or name.
List the transcripts of a certain course taught by a teacher, and display them in ascending or descending order.
List all course information taught by a teacher.
Query the credit information a student has obtained.
Statistics on the average score, highest score, and lowest score of a certain teacher's course.
Add a new course.
Modify the credits of a certain course.
Create a deletion trigger. When a student with a "student number" in the student table is deleted, the student's course selection record in the course selection table will be automatically deleted. That is, a deletion trigger will be created for the student table to achieve Cascade deletion of student table and course selection table.
Create a deletion trigger. When a course with a certain "course number" in the course schedule is deleted, all records for that course in the course selection list will be automatically deleted, that is, a deletion trigger will be created for the course schedule. Implement cascade deletion of student table and course selection table.
Create an insert trigger. When inserting a record into the course selection table, query whether there is a student with the student number in the student table, and whether there is a course with the course number in the course table. If there is a record, it can be inserted. Otherwise the insertion is refused.
Back up the "Student Course Selection System" database to the BACKUPDB folder under the E drive of the local disk.
sp_addumpdevice 'disk','Student Course Selection System_bak','E:\BACKUPDB\Student Course Selection System_bak'
BACKUP DATABASE Student Course Selection System TO DISK='Student Course Selection System_ bak'
Book borrowing management system
Requirements analysis:
The system should implement the following functions: librarians can maintain book information, including adding new books, modifying book information, and processing Book borrowing registration, return registration, expired book processing, lost book processing, and maintenance of reader borrowing certificate information, etc. Readers can borrow books, return books, check book information, borrow book information, etc. The specific requirements are as follows:
Book information management: enter each book information, maintain book information, etc.
Reader information management: Maintain reader information and modify, update, and delete readers according to actual needs
Borrowing management: including borrowing books, returning books, and returning expired books, etc.
The book lending management system mainly has two types of users.
Administrator: Maintain basic book data, including book types, update book information, and process readers' book borrowing and return.
Reader users: can check book information and borrow books.
Semantics: The book situation and management regulations of the library. Each type of book has many different books, and the same book can be read multiple times; each book can be borrowed multiple times, and each reader can borrow multiple times. This book. The borrowing period for each book is one month.
Database conceptual structure design:
Completed in 3 steps: 1) Abstract the entity 2) Abstract and connect with reality) Determine the attributes and keys of the entity
Book type, including : Book category number, book category name, description information.
Books, including: book number, book title, author, publisher, price.
Readers, including: ID number, name, gender, department, class, ID status (including valid and invalid), contact information, etc.
The relationship between readers and books is m:n, the relationship between book types and books is 1:n, and there is no connection between readers and book types.
Database logical structure design:
Convert the E-R diagram into a relational model.
Optimize the relational model
Normalize to the third normal form
Physical design and implementation of database:
Mainly include the following work:
Create database
Create basic tables, set constraints, and manage basic tables.
Create and manage indexes. (DBMS will automatically create an index for the primary key. Create an index to improve query efficiency.)
Create and manage views.
Enter data into the database.
Use SQL statements to perform operations such as data query, modification, and deletion. (You can think about how to manipulate the database first, and then implement it later)
Write stored procedures, triggers, etc., and pass debugging.
Manipulate the data in the database
In order to facilitate the administrator's classification management, it is now necessary to create views for multiple book types.
Create a reader borrowing status table.
Create a combined sub-index for the document number and borrowing date in the borrowing table.
Create indexes for the book classification number, book title, and publisher fields in the book table.
Create an insertion trigger for the borrowing table to ensure that the "certificate number" inserted into the borrowing table exists in the reader table. If it does not exist, the borrowing information record will not be inserted into the borrowing table.
Create an update trigger in the borrowing table and monitor the "Borrowing Date" column of the borrowing table so that it cannot be modified manually.
Create a delete trigger in the reader table to implement cascade deletion of the reader table and borrowing table.
Sports Games Management System
Requirements Analysis:
Introducing computers to manage sports games. Athletes can check their own competition events and results, referees or staff in the sports meeting management system. The system can record athletes' results in various competitions and perform performance statistics, etc. The sports meeting management system saves the participation data of athletes, competition events and different types of competitions.
The main management objects of the sports meeting management system include representative teams, athletes, competition events, etc.
In this system, the basic regulations are as follows: a representative team contains multiple athletes, and an athlete can only belong to one representative team; an athlete can participate in multiple competition events, and a competition event can be participated by multiple athletes; Assume that after each competition event is completed, the rankings will be ranked from high to low, and the top three athletes will be given corresponding points. For example, the points for the 1st, 2nd, and 3rd place will be 3, 2, and 1 points respectively, and other rankings will be given. The athlete's points are zero points. The points of all members of the representative team are accumulated to obtain the total points of each representative team. The total points are sorted from high to low to obtain the ranking of each representative team.
In order to simplify the system requirements, this sports meeting management system only considers the management of track and field games, only considers the relationship between representative teams, competition events, and does not consider the arrangement of referee scores, competition time, location, etc.
Database conceptual structure design:
Representative team: representative player, team name, team leader, total points, total ranking
Athlete: athlete number, name, gender, age
Competition items: project number, project category, project name, performance unit.
Database logical structure design:
4 tables,
competition details, including results, points, and rankings
The above are the general steps for designing a database and With all the examples, I believe you already have a general idea of how to design a database.
Related tutorials:
Restore the database, the database prompts that the database is being restored
An example of a joint query about the database
The above is the detailed content of General steps and examples of designing a database. For more information, please follow other related articles on the PHP Chinese website!

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

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

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





WeChat is one of the social media platforms in China that continuously launches new versions to provide a better user experience. Upgrading WeChat to the latest version is very important to keep in touch with family and colleagues, to stay in touch with friends, and to keep abreast of the latest developments. 1. Understand the features and improvements of the latest version. It is very important to understand the features and improvements of the latest version before upgrading WeChat. For performance improvements and bug fixes, you can learn about the various new features brought by the new version by checking the update notes on the WeChat official website or app store. 2. Check the current WeChat version We need to check the WeChat version currently installed on the mobile phone before upgrading WeChat. Click to open the WeChat application "Me" and then select the menu "About" where you can see the current WeChat version number. 3. Open the app

When logging into iTunesStore using AppleID, this error saying "This AppleID has not been used in iTunesStore" may be thrown on the screen. There are no error messages to worry about, you can fix them by following these solution sets. Fix 1 – Change Shipping Address The main reason why this prompt appears in iTunes Store is that you don’t have the correct address in your AppleID profile. Step 1 – First, open iPhone Settings on your iPhone. Step 2 – AppleID should be on top of all other settings. So, open it. Step 3 – Once there, open the “Payment & Shipping” option. Step 4 – Verify your access using Face ID. step

Having issues with the Shazam app on iPhone? Shazam helps you find songs by listening to them. However, if Shazam isn't working properly or doesn't recognize the song, you'll have to troubleshoot it manually. Repairing the Shazam app won't take long. So, without wasting any more time, follow the steps below to resolve issues with Shazam app. Fix 1 – Disable Bold Text Feature Bold text on iPhone may be the reason why Shazam is not working properly. Step 1 – You can only do this from your iPhone settings. So, open it. Step 2 – Next, open the “Display & Brightness” settings there. Step 3 – If you find that “Bold Text” is enabled

Screenshot feature not working on your iPhone? Taking a screenshot is very easy as you just need to hold down the Volume Up button and the Power button at the same time to grab your phone screen. However, there are other ways to capture frames on the device. Fix 1 – Using Assistive Touch Take a screenshot using the Assistive Touch feature. Step 1 – Go to your phone settings. Step 2 – Next, tap to open Accessibility settings. Step 3 – Open Touch settings. Step 4 – Next, open the Assistive Touch settings. Step 5 – Turn on Assistive Touch on your phone. Step 6 – Open “Customize Top Menu” to access it. Step 7 – Now you just need to link any of these functions to your screen capture. So click on the first

Is the clock app missing from your phone? The date and time will still appear on your iPhone's status bar. However, without the Clock app, you won’t be able to use world clock, stopwatch, alarm clock, and many other features. Therefore, fixing missing clock app should be at the top of your to-do list. These solutions can help you resolve this issue. Fix 1 – Place the Clock App If you mistakenly removed the Clock app from your home screen, you can put the Clock app back in its place. Step 1 – Unlock your iPhone and start swiping to the left until you reach the App Library page. Step 2 – Next, search for “clock” in the search box. Step 3 – When you see “Clock” below in the search results, press and hold it and

Facing lag, slow mobile data connection on iPhone? Typically, the strength of cellular internet on your phone depends on several factors such as region, cellular network type, roaming type, etc. There are some things you can do to get a faster, more reliable cellular Internet connection. Fix 1 – Force Restart iPhone Sometimes, force restarting your device just resets a lot of things, including the cellular connection. Step 1 – Just press the volume up key once and release. Next, press the Volume Down key and release it again. Step 2 – The next part of the process is to hold the button on the right side. Let the iPhone finish restarting. Enable cellular data and check network speed. Check again Fix 2 – Change data mode While 5G offers better network speeds, it works better when the signal is weaker

Can't enable Wi-Fi calling on iPhone? Call quality is improved and you can communicate even from remote locations where cellular networks are not as strong. Wi-Fi Calling also improves standard call and video call quality. So, if you can't use Wi-Fi calling on your phone, these solutions might help you fix the problem. Fix 1 – Enable Wi-Fi Calling Manually You must enable the Wi-Fi Calling feature in your iPhone settings. Step 1 – For this, you have to open Settings. Step 2 – Next, just scroll down to find and open the “Phone” settings Step 3 – In the phone settings, scroll down and open the “Wi-Fi Calling” setting. Step 4 – In the Wi-Fi Calling page, change “This iPhone

Are you trying to record something on your phone screen and it's going black? Typically, you can initiate screen recording from Control Center. In some cases, you cannot record items on the screen. We have mentioned all the scenarios along with the list of possible solutions that can help you record your screen properly. Reasons why screen recording goes black – If you try to record any DRM (Digital Rights Management) protected content while it’s playing on your iPhone screen, you won’t get anything. The output will be a pitch black screen. All leading OTT platforms like Netflix, Disney+, Hulu, and Peacock have this DRM that blocks any screen recording functionality. 2. Several websites prohibit the use of screen capture
