[关闭]
@openxy 2016-10-27T19:09:32.000000Z 字数 1260 阅读 1225

第七周(10.24-10.29)分享

2016实验班

restful

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()

database models and diagram 数据库模式

1 to 1

one user has one profile

users

字段 说明
id prmary key; auto increment
... 其它字段

profiles

字段 说明
id auto increment
user_id forigen key ; is null ?
...

约束:外键约束、级联删除与更新;

1 to n

one user has 2+ phone numbers

users

字段 说明
id prmary key; auto increment
phone string or array ; 如"13957451234,189121341234"

1 to N

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 ?
...

n to N

one author has many blogs
one blog has 2+ authors
one blog belongs to 2+ author
one author belongs to many blogs

N to N

one blog has many authors
one blog has many authors
one blog belongs to many author
one author belongs to many blogs

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注