Build a database-driven website using PHP and MySQL (8)

Source: Internet
Author: User
Tags php and php and mysql mysql command line
Summary
In this chapter, we will expand our example, learn some new knowledge about MySQL, and try to understand and master the functions that RDs can provide.
(14:11:39)
--------------------------------------------------------------------------------
By Wing, source: Linuxaid
Chapter 5: Relational Database Design
In the second chapter of this article, we have created a very simple joke database for our use, which only contains a data table named Jokes. This is enough for us to get started with MySQL databases, but there are many other things in the design of relational databases. In this chapter, we will expand our example, learn some new knowledge about MySQL, and try to understand and master the functions that RDs can provide.
First, we must note that our solutions to many problems are not formal (that is, informal ). As you know in many computer science majors, database design is a serious field. Database design must include testing it and involves mathematical principles. However, these may be beyond the scope of our article. To get more information, you can stop at the terminal.
Grant Due permissions
Before we start, let's recall the structure of our Jokes data table. This table contains three columns: ID, JokeText, and JokeDate. These columns enable us to identify joke (ID), understand their content (JokeText) and the time they are added (JokeDate ).
Now we want to save some other information in our joke: the name of the submitter. This looks natural. We need to add a new column in our Jokes data table. The SQL ALTER command (we have never seen this command before) can help us complete this task. Use the mysql command line program to log on to the MySQL server, select your database (if you use the name in chapter 2, the database name should be joke), and then enter the following command:
Mysql>
Alter table Jokes ADD COLUMN
-> AuthorName VARCHAR (100 );

This will add an AuthorName column in our data table. Its data type is a variable-length string with a maximum length of 100 characters (this should be sufficient for the most complex names ). Let's add another column to save the author's email address:
Mysql> alter table Jokes ADD COLUMN
-> AuthorEMail VARCHAR (100 );

For more information about the ALTER command, see the MySQL Reference Manual. To confirm whether we have correctly added two columns, you can ask MySQL to describe the table for us:
Related Article

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.