数据库设计:捕获用户/朋友关系的最佳表结构? [英] Database design: Best table structure for capturing the User/Friend relationship?

查看:18
本文介绍了数据库设计:捕获用户/朋友关系的最佳表结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设计一个数据模型,该模型表示一个用户是另一个用户的朋友.这是我目前想到的,但看起来很笨拙,有没有更好的解决方案?

I'm trying to design a data model that denotes one user being the friend of another user. This is what i've come up with so far, but it seems clunky, is there a better solution?

User
=====
Id
Name
etc...

UserFriend
===========
UserId
FriendId
IsMutual
IsBlocked

推荐答案

UserRelationship
====
RelatingUserID
RelatedUserID
Type[friend, block, etc]

同意相互性不属于列;打破正常化.

Agree that mutuality doesn't belong as a column; breaks normalization.

这篇关于数据库设计:捕获用户/朋友关系的最佳表结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆