nothings gonna change my love using the MySQL Date/Time type

WBOY
Release: 2016-07-29 08:37:30
Original
1043 people have browsed it

Since I used to be in the same team as him, I am very familiar with his "mesophobic" approach, and I strongly agree with many of his views; but one thing I don't understand very much is that when designing a database, I always Will avoid using Date/Time type. What he did was to set the time-related fields to the INT(10) type, and then use UNIX timestamps to store them. I personally strongly disagree with this approach:
First of all, it is the difference in type operations. The "time calculation" similar to wiLdGoose's method is essentially an operation between integers (and this integer is very large, with a length of 10) . What's more, setting the timestamp to VARCHAR(10) causes efficiency problems that are self-evident.
As for the efficiency of time calculation, shaping calculation and even string calculation, this article is very illustrative.
Secondly, there is the operational issue of logic. This is an advantage of using time types, especially on projects that require high precision. For example, if you need "the data of the previous week" and "get the data of every Monday since the database was created", the complexity of such operations can be imagined if you use brother wiLdGoose's approach.
Finally, there is the problem of intuitiveness and unintuitiveness. It is understandable that our brains will not directly convert this large series of timestamps into date format. In comparison, it is obviously much more intuitive to use the time type directly (it is a time format itself).
And my current team is still using a similar method. I have also argued about similar technical details for a long time, but due to issues of position and decision-making power, the team still cannot adopt my opinions, which is a pity.
MySQL is positioned as a simple and fast DBM, which can naturally be quickly controlled, but on the other hand, it can easily lead to a situation that does not go further. For this, we should pay more attention to the database design details of each item. A product that continuously adds new functions is ultimately application-oriented.
Finally, here is the official MySQL time and date function manual.

The above has introduced nothings gonna change my love using the MySQL Date/Time type, including the content of nothings gonna change my love. I hope it will be helpful to friends who are interested in PHP tutorials.

source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template