MyBatis know how (8) relational database

Source: Internet
Author: User

The existence of MyBatis is to simplify access to relational databases. Databases are really complex, and it takes a lot of work to use them correctly. The database is responsible for managing data and modifying data. The reason we use a database instead of simply using a flat file is because the database provides us with many benefits, especially in terms of data integrity, performance, and security.

Data integrity

Data integrity is probably the most important benefit that the database provides, because without data integrity, everything else is meaningless. If the data are not consistent, reliable, and correct, then how much value do they have? The database uses strong data types, enforces constraints, and uses transactions to achieve data integrity requirements.

A database is strongly typed, that is, once a database table is created, each of its columns is designated to store only a certain type of data. The database management system guarantees that the type of data stored in the table is correct relative to the column. For example, a table might define a column as varchar (25> not NULL). This guarantees that the data stored in the column is character and does not exceed 25 in length, and that the not NULL portion of the definition guarantees that the data is required, that is, you must provide a value for the column.

In addition to strong data types, you can use some additional constraints on database tables. These constraints are generally broader in scope because they tend to handle more than just one column. Constraints typically involve validation of multiple records (even multiple tables) in a table. For example, a unique constraint ensures that the values of the specified columns in the table are not duplicated. such as the foreign key (FOREIGN key) constraint, this constraint guarantees that the value of a column in the table must come from the related column in the associated table. FOREIGN KEY constraints are used to describe relationships between tables, so it is important and indispensable for relational database design and data integrity.

One of the most important ways to maintain data integrity in a database is to use transactions. Most business functions need to use many types of data, often from different databases. Typically, this data is interrelated in some way, so it needs to be updated consistently. Using transactions, the database management system ensures that all relevant data is updated in a consistent manner. More importantly, transactions allow multiple users of the system to update data at the same time without causing conflicts. There is a lot of knowledge to be learned about transactions.

Performance

Relational databases can help us get high performance that is hard to get when using tablet files. In other words, database performance is not free and you need a lot of time and expertise to get high performance. Database performance can be divided into 3 key factors: design, software tuning, and hardware.

To improve the performance of the database, the first factor to consider is the design. A poor relational database design brings inefficiencies that can be corrected with more software tweaks and additional hardware. A bad design can cause deadlocks, exponential relational operations, or a database table scan of millions of records. The right design is very important.

For large databases, software tuning is the second most important factor to consider in improving performance. Adjusting the relational database system requires a dedicated and experienced professional who has been trained in the specific RDBMS software we use. While some of the features of the RDBMS software claim to be across different products, there are often subtle and subtle differences in each product, and therefore require professionals for that particular software. Performance tuning can bring some great benefits. For example, just a database index adjustment can change a complex query that would otherwise have taken several minutes into just a few seconds. There are many parts of the RDBMS that can be adjusted, such as caching, file management, various indexing algorithms, and even operating system considerations. The behavior of the same RDBMS software on different operating systems may be different, so different operating systems will have to be adjusted differently. Needless to say, tuning the database software anyway requires a lot of effort. How the database should be adjusted is beyond the scope of this book, but it is important to know that software tuning is also a very important factor in improving database performance. Coordinate well with the DBA (that is, the database administrator).

Large relational database systems usually have higher requirements for computer hardware. It is for this reason that many of the most powerful servers in a company are often database servers. In many companies, the database is their "center of the Universe", so it is no surprise that the hardware of the database has invested a lot of money. Fast disk arrays, I/O controllers, hardware caches, and network interfaces all are critical to the performance of large database management systems. With this, you can no longer use hardware as an excuse for poor database design or as an alternative to RDBMS tuning. Hardware should not be taken to address performance issues-it should be used to meet performance requirements. More in-depth discussion of hardware is also beyond the scope of this book, but it is important to consider this factor when you use a large database system. You are also asked to coordinate well with your DBA.

Security

The relational database system also provides additional security. The amount of data we use in our daily work is confidential. In recent years, personal privacy has become a growing concern, and security has been a basic requirement for all data. For this reason, even simple information such as the full name of a person can be considered confidential because it is a potentially unique identifying information.
Other information, such as Social Security numbers and credit card accounts, requires a higher level of security like strong encryption. Most commercial relational databases include many advanced security features that allow finer granularity of security and data encryption. Each database has its own unique security requirements. The most important thing is that you understand them because the application code must not weaken the security policy of the database.

Different databases have different levels of data integrity, performance, and security. Typically, the size of the database, the value of the data, and the number of people involved in the database determine these levels.

Series Articles:

MyBatis know how much (1)

MyBatis know how much (2)

MyBatis know how much (3)

MyBatis know how (4) The advantages of MyBatis

MyBatis know how much (5) Business object model

MyBatis know how (6) presentation layer and business logic layer

MyBatis know how much (7) persistence layer

MyBatis know how (8) relational database

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.