我的客户想要在他们的网站上添加新的功能,他们与演员/模型打交道,并希望能够为每个客户创建信用记录(很像简历或简历)。
他们有一些我必须遵守的标准,正因为如此,我无法理解它。
信用可以是两种情况之一,它可以是4列信用,也可以是单列信用。然而,信用必须有一个类别,这些类别可以是以下之一,电视,电影,广告,广播或自己制作的东西。
第二个标准是类别是可排序的,因此,例如,如果他们正在输入演员的片头,他可能会有电视和电影片头,他们可能会时不时地在电视上拍摄电影。
第三个标准是每个类别的积分都是可订购的,因此film1积分不必位于顶部。
这是我到目前为止设计的东西。
CANDIDATES | CREDITS
---------- -------
candidate_id^ credit_id*
credit_category
credit_heading
credit_title
credit_role
credit_director
credit_position
candidates_candidate_id^^ ^-主键
^^ -外键
我的困惑来自于使用这种表结构无法改变类别的顺序,就像我添加了一个credit_category_position一样。
例如,如果用户在类别电影中有一个信用,而我想添加另一个,当我通过我的表单插入数据时,我如何保持所有客户电影条目的credit_category_position一致?
我希望这对某些人来说是有意义的。
发布于 2012-01-04 22:42:16
我只是浏览了一下你的问题,我不确定我是否完全理解了它,但有一件事突然出现在我的脑海中:
为什么不在candidates和credits之间建立一个many-to-many relationship
CANDIDATES | CREDITS
---------- -------
candidate_id^ credit_id*
credit_category
credit_heading
credit_title
credit_role
credit_director
CANDIDATE_CREDIT_REL
--------
rel_id*
credit_id^^
candidate_id^^
credit_position 发布于 2012-01-04 23:06:34
信用可以是两种情况之一,它可以是4列信用,也可以是单列信用。
我将跳过这一部分,因为我不理解它,而且您的描述中没有任何内容可以帮助我解决它。请随时编辑您的问题。
第二个标准是类别是可排序的
你需要一个额外的表格,因为每个候选人可以有多个学分,比如说电影。
create table credit_category_order (
candidate_id integer not null,
credit_category <whatever> not null,
category_order float not null, -- lets you reorder by splitting the difference,
-- but there are other ways.
primary key (candidate_id, credit_category),
foreign key (candidate_id, credit_category)
references credits (candidate_id, credit_category)
);第三个标准是每个类别的积分都是可订购的
将列添加到制作者名单。查询时,连接credit_category_order和ORDER BY credit_category_order.category_order, credits.credit_order。
发布于 2012-01-04 23:22:37
Credit_Category
----------
id, category_name, details
Actor_cc_order //For each actor, have an entry for every category
----------
id, id_actor, id_cc, ord_number
Actor_credit
------------
id, id_actor, id_cc, credit_details查看制作者名单
SELECT a.*, b.category_name, c.ord_number FROM
Actor_credit a
JOIN Credit_category b ON b.id = a.id_cc
JOIN Actor_cc_order c ON c.id_actor = a.id_actor AND c.id_cc = b.id
SORT BY a.id_actor, c.order_numberhttps://stackoverflow.com/questions/8728514
复制相似问题