Home  >  Q&A  >  body text

mysql - 大表和小表关联, 在哪个表上建立关联字段, 使查询效率更高

大家讲道理大家讲道理2718 days ago701

reply all(3)I'll reply

  • 巴扎黑

    巴扎黑2017-04-17 16:41:48

    When two tables establish a one-to-many relationship, the "one" end is the parent table, and the "many" end is the child table.
    General
    Set the primary key in the parent table
    Set the foreign key in the child table
    According to your choice: Method 2

    reply
    0
  • PHPz

    PHPz2017-04-17 16:41:48

    Method 2, but it is not recommended to build foreign keys on the database

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-17 16:41:48

    Method 1 + Method 2 together, because I want to conveniently query the current version of the file and make data redundant, haha

    reply
    0
  • Cancelreply