users
id | name |
posts
| id | u_id | content |
wall
| id | u_id | post_id |
u_id fromposts
是 users.id,它是 Author
u_id fromwall
是 users.id,它是 Target(贴在墙上)
你可以更清楚地命名它,即poster_id,target_id
另一种方法是拥有
post
| id | poster_id |
wall
| id | post_id | target_id |
content
| post_id | content |
您还可以添加其他特定的内容,例如帖子是否是评论或其他内容,在另一个表格中或表格中的post
列
function getUsersWallPosts($target_id) {
$query = "SELECT c.content FROM content AS c, INNER JOIN wall AS w ON w.post_id = c.post_id WHERE w.target_id = $target_id";
$result = someUserDefinedFunctionForQueryAndFetch($query);
return $result
}