@openxy
2016-10-27T11:09:32.000000Z
字数 1260
阅读 1342
2016实验班example
get /posts /posts.xml => index()
get /posts/1 /posts/1.json => show()
post /posts => create()
put /posts/1 => update()
delete /posts/1 => destroy()
patch /posts/1/to_top => to_top()
get /posts/1/authors => author#index()
one user has one profile
users
| 字段 | 说明 |
|---|---|
| id | prmary key; auto increment |
| ... | 其它字段 |
profiles
| 字段 | 说明 |
|---|---|
| id | auto increment |
| user_id | forigen key ; is null ? |
| ... |
约束:外键约束、级联删除与更新;
one user has 2+ phone numbers
users
| 字段 | 说明 |
|---|---|
| id | prmary key; auto increment |
| phone | string or array ; 如"13957451234,189121341234" |
one user has many blogs
one blog belongs to one user
users
| 字段 | 说明 |
|---|---|
| id | prmary key; auto increment |
| ... | 其它字段 |
blogs
| 字段 | 说明 |
|---|---|
| id | auto increment |
| user_id | forigen key ; is null ? |
| ... |
one author has many blogs
one blog has 2+ authors
one blog belongs to 2+ author
one author belongs to many blogs
one blog has many authors
one blog has many authors
one blog belongs to many author
one author belongs to many blogs