How to create an associated mysql table? what is the book video that is used to operate a single table?

Source: Internet
Author: User
Tags open source cms
How to create an associated mysql table-PHP, which is usually used for single-table operations, has never made any progress. recently, after reading a few open-source articles, it has become more dynamic.

Books and videos that have been read all the time are operations on a single table.
Now we need to implement a function to record the field names and tables of some open source CMS data tables.
For example, I want to record all ecshop tables and write the field names, types, and annotations of each table to the database to save them.

Similar to this, I designed such a database in this way. There are two tables.

The first table one (record table information, tabid associated with the tid of the second table)
Auid int (3) auto-increment, primary key
Tabname varchar (30) table name
Tabnote varchar (table comment)
Tabid int (3) associate tid in the two table
Addtime int (10) Add table timestamp


Second table two (record table field information)
Auid int (3) auto-increment, primary key
Tname varchar (30) field name
Ttype varchar (20) field type
Description and comment of the tnote varchar (100) field
Tid int (3) associates tabid of one in the first table

========================================================== =
In this case, how can we automatically associate the database? I just don't know how to implement it. for example, now I insert a piece of data
Table name: article_cat
Table comment: Document category information
Table addition Time: 1395052170
Field: type
Field type: time
Field Description: This is the timestamp.

-----------------------
In this case, how can I insert a database after receiving information through POST?

Insert ......

Is there any problem with the design of the above table? do you have to set the table-related fields to primary keys.


Reply to discussion (solution)

The auid and tabid in the first table are repeated. you can use one.
If there is no automatic association, you need to write data in the association field.

The auid and tabid in the first table are repeated. you can use one.
If there is no automatic association, you need to write data in the association field.

You mean that the tabid written to the one table must be automatically inserted to the tid of the two table while being written. Is that true?

In this case, does mysql triggers need to be used?

Then we need to write two SQL statements. one is to insert the one table and the other is to insert it to the two table. can this be understood?

We recommend that you first learn basic knowledge such as database paradigm.


The auid and tabid in the first table are repeated. you can use one.
If there is no automatic association, you need to write data in the association field.

You mean that the tabid written to the one table must be automatically inserted to the tid of the two table while being written. Is that true?

In this case, does mysql triggers need to be used?

It is not as complicated as you think. after saving the value of a column, you can assign the value of this column to the corresponding column of another table...

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.