当前位置:网站首页>Differences between belongsto and hasone
Differences between belongsto and hasone
2022-06-09 08:10:00 【xcbzsy】
hasOne Positive correlation ,belongsTo Reverse correlation .
In short, it's , No big difference , It's just a deviation in logic ( Logical rationality ).
belongsTo: It can be understood as belonging to
hasOne: It can be understood as having
First , We create two tables .
user surface Field id name password Field
user_address surface id user_id city Field
It's not hard to see. ,user_address Is based on user Extended tables . We can say ,user Have user_address The foreign key ,user_address Foreign key for user.
User Association in the model user_address When using tables hasOne
UserAddress Association in the model user When using tables belongsTo
You can understand :
I (User) Have (hasOne) A it (user_address), I (user_address) Belong to (belongsTo) it (User).
边栏推荐
- R language uses dlnorm function to generate lognormal distribution density data and plot function to visualize lognormal distribution density data
- Robot_ Framework: assertions
- On the readable and writable conditions of socket
- "Sprint to Dachang foundation 2"
- Clickhouse distributed table & local table & Clickhouse realize time series data management and mining
- js正则表达式匹配span标签
- JS regular expression matching span tag
- MySQL: connection query
- 图解知识点:leakcanary
- Market Research - current situation and future development trend of Brazil berry oil market in the world and China
猜你喜欢

C语言复习7

At time_ What happens to TCP connections in wait status after SYN is received?

ftp服务

ELK+Filebeat 部署安装

Summary of MySQL knowledge points

SQL or NoSQL, you will understand after reading this article

MySQL: single table query

No, you still can't read the log with requestid?

IELTS复习1

Personal feeling: Hello, teacher. My name is he
随机推荐
xml-json-yaml 互转
China GaAs industry chain research and investment strategy report (2022 Edition)
刘勇智:一码通缺陷分析与架构设计方案丨声网开发者创业讲堂 Vol.02
At time_ What happens to TCP connections in wait status after SYN is received?
(13) Cross compilation and memory leak detection of Valgrind on ARM
[reading point paper] ghostnet: more features from cheapoperations convolution operation is still expensive, and feature graph redundancy can be obtained by linear transformation
Market Research - current situation and future development trend of zirconia grinding wheel Market in the world and China
Sql Or NoSql,看完这一篇你就懂了
【读点论文】MobileDets: Searching for Object Detection Architectures for Mobile Accelerators,适配不同硬件平台的搜索方案
Market Research - current market situation and future development trend of cosmetic grade ethylhexyl glycerol in the world and China
ehcache
Redis---07---basic command operations of redis (mainly about how to expand the struct and map of go into redis parameters, and how to use struct to obtain the key value batch array returned by redis)
企业运用通兑吧数字会员卡进行营销的优势
【读点论文】EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks网络结构要像身材一样匀称且体量和处理能力匹配
MySQL: grouping query
【读点论文】Benchmark Analysis of Representative Deep Neural Network Architectures当准确率不再是唯一衡量标准,给多目标优化一个导向
Advantages of enterprises' marketing with universal cash bar digital membership card
Robot_ Framework: assertions
C language review 7
PHP get last Monday, get the last week date of the specified date, last Monday