search

Home  >  Q&A  >  body text

mysql - What is the use of table name prefix?

So many companies' projects add a prefix word to the table name when designing the table, but what is the use of this? Looking at the whole project, I didn't find this useful

高洛峰高洛峰2776 days ago1407

reply all(10)I'll reply

  • 天蓬老师

    天蓬老师2017-06-09 20:12:57

    Prefixing the table name was a popular way before. The current trend is to abandon adding prefixes because the benefits it brings are far less than the problems it brings. In many cases, cross-database design is more flexible and practical than table prefix design, and the confusion and problems caused by prefix design (especially in mixed situations) are the biggest trouble for many novices. So please be careful.

    reply
    0
  • 浴后重生

    浴后重生2017-06-08 17:27:26

    Easy to manage

    reply
    0
  • 大家讲道理

    大家讲道理2017-06-08 11:05:32

    It will be useful if you put multiple projects in the same database

    Project 1 user table - p1_user
    Project 2 user table - p2_user

    You will understand once you say this

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-06-08 11:05:32

    It’s just a design habit. It is usually created to distinguish different system tables in the same library.

    As shown in the picture, the table without prefix is ​​the table of the background management system. The table with wms prefix is ​​the table of wms system

    reply
    0
  • 高洛峰

    高洛峰2017-06-08 11:05:32

    To be honest, it is more appropriate to divide different types of tables according to the database. The prefix thing is really cumbersome

    reply
    0
  • 代言

    代言2017-06-08 11:05:32

    The

    prefix is ​​very useful. For example, if I want to know all the tables about user, I can just show tables like '%user%', and use the mysqlcommand line to find out

    Especially for projects with many plug-ins or modules, adding these prefixes is also helpful for batch processing of database tables and other operations

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-06-08 11:05:32

    Used to distinguish all projects using data tables of different projects in the same database

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-06-08 11:05:32

    The prefix of the table name is just a naming convention and has no impact on function implementation.

    In more complex systems, you can roughly understand the module and classification of the table through the table name prefix. This seems more convenient during daily development and operation and maintenance, and newcomers also have rules to follow when understanding the system data structure.

    Personally I agree with this approach. The cost is very low, but it is convenient for later operation and maintenance. Why not do it?

    reply
    0
  • 为情所困

    为情所困2017-06-08 11:05:32

    When the data tables are in one database, and there are many data tables, the distinction is very straightforward

    reply
    0
  • 黄舟

    黄舟2017-06-08 11:05:32

    When there are more than 100 tables in a project, you will understand why you need to use them.

    Ideally, user_tabel1 can be written as user.table1 (to create multiple libraries)
    The problem is that many developers only know databases by simply adding, deleting, modifying, and checking, including many frameworks (which can only connect to one library)

    For example, Oracle’s most classic scott instance.
    scott has a list of departments and department personnel, hr (another instance) has a list of departments. There is also a product instance that has a list of products.
    The hr instance has a list of scott. emp has select permission but no update permission

    Personally, I feel that this design improves data security (when an instance is attacked and cracked, all data will not be exposed) and logical clarity is greatly improved, but it also requires developers to Have more understanding and mastery of the database.
    But what we often see is that all the tables of developers are placed in one library. The control of permissions is only controlled from the business logic.

    (The above is my personal understanding)

    reply
    0
  • Cancelreply