Home  >  Article  >  Backend Development  >  Detailed explanation of the process of establishing a MYSQL database with phpmyadmin_PHP tutorial

Detailed explanation of the process of establishing a MYSQL database with phpmyadmin_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:29:13841browse

First create a database named webjxcom. Create a data table under this database named Article. Let's move on to a key point, which is to create various fields under the table Article.

So, what is a field? In layman's terms, it is a general term for a category of things. For example, all news publication times are represented by a noun. We use "time" to represent it. The field we create the title of the news is "title". In fact, we can make the content under each title or time correspond to a number, that is the field -

"id": The field "id" is a default preferred field, and the content under other fields can appears repeatedly, but this field is an Arabic numeral starting from 1 and increasing. When setting this field, set the primary key, index, unique and auto-increment. This auto-increment means automatic increase. When content is added to any field, this field will automatically increase by 1. That is to say, any field corresponds to a unique id, such as 1, 2, 7...

Let’s talk about the news Creation of some fields.

1. id: The meaning is the number of each news, it is unique, the type is tingint, this tingint type does not need to specify the length, the system defaults to 4; select auto- in "Extra" increment and select the primary key.

2. author: The meaning is the author (news publisher), the setting type is varchar. When setting the length of this field, if the authors are all Chinese, the upper limit is 8 bytes (4 Chinese characters) , but if you consider that the author may be a foreigner, 8 bytes is obviously too few. The same problem exists for other fields, so let’s set the length to 8 here.

3. title: The meaning is the news title, the type is varchar, the length is 60

4. content: meaning news content, type text. This type does not need to set the length.

5. from: The meaning is the source of the news, the type is varchar, the length is 60.

6. addtime: meaning is publication time, type is datetime, length does not need to be set
7.hits: means click rate. The type is varchar and the length is 60

Below is the relevant content of the following field types:

1. date: Time and date types. Time and date types also include the following:

⊕ datetime : 0000-00-00 00:00:00

⊕ date: 0000-00-00

⊕ timestamp: 00000000000000 (14 zeros, the length depends on the display size)

⊕ time: 00:00:00

⊕ year: 0000

2. The content field represents the news content. Since its capacity may be large, it uses the text type (supports up to 65535 bytes)

3. The title field is set as primary key. If there is not more than one news with the same publication time, the date field can also be used as primary key, so that sorting and retrieval of news will be more convenient in the future.

4. Although the text type field also belongs to a character type, its size cannot be specified. If the length is set, the system will prompt an SQL statement error.

Now, the article data table is created.

Since not everyone can add news, only administrators can do it, so now we create a data table member to store administrators.

1: id: type is tinyint, additionally set to auto-increment, primary key.

2: username: The meaning is the user name, the type is varchar, the length is 8, and the attribute is primary key.

3: userpass: Meaning is password, type is varchar, length is 32.

4: email: meaning is the email address, type is varchar, length is 30.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/531687.htmlTechArticleFirst create a database named webjxcom. Create a data table under this database named Article. Let's move on to a key point, which is to create various fields under the table Article. ...
Statement:
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