gpt4 book ai didi

mysql - 多对多关系mysql设计

转载 作者:行者123 更新时间:2023-11-29 13:01:36 24 4
gpt4 key购买 nike

许多用户可以有很多选项卡,所以我设计了这个表格

user
uId (PK)



user-tab
uId (FK)
tabId (FK)



tab
tabId (PK)

但是当我尝试添加FK时在user-tab我收到这个错误

1050 - Table '.\db\tab@002duser' already exists 

最佳答案

这不是您的数据库设计或现有记录的问题,而是命名问题。

MySQL 命名不带引号的标识符的规则是 snake_case_writing 而不是 CamelCasedash-style-writing,使用

来自Docs :

Permitted characters in unquoted identifiers (not strings, values):

ASCII: [0-9,a-z,A-Z$_] (basic Latin letters, digits 0-9, dollar, underscore)

Extended: U+0080 .. U+FFFF

编辑

文档的另一个节选(此内容以及更多内容需要阅读 here )

Naming Conventions For identifiers formed from multiple words,separate each component with underscore rather than capitalization.Thus, use my_var instead of myVar or MyVar.

Avoid capitalization except for class names; class names should beginwith a capital letter.

class Item; class Query_arena; class Log_event; Avoid function names,structure elements, or variables that begin or end with '_'.

Use long function and variable names in English. This will make yourcode easier to read for all developers.

关于mysql - 多对多关系mysql设计,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23260824/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com