This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / Small company, one poor junior programmer has to do the DB design work. need helpRequirement:
One online book store :
One order can hold multile books:
Order table:
id Name quantity
Book table
id name price
How to create the relations between this two table, it seem we need to create another third table? How design
Thanks for your kind help.
-aaaaaaaa(aaaa);
2002-9-24
{282}
(#764876@0)
-
跟你们头儿说一下,我给你们作VOLUNTEER,行不?book_table
book_id, --primary key
book_name,
unit_price,
author,
isbn,
publisher_id,
....
order_table
order_id,
order_date,
customer_id,
...
order_item_table
order_id, ---\ primary key
line_no, ---/
book_id, --foreign key
unit_price,
quantity,
sub_total,
...
-mickeymouse(米老鼠);
2002-9-24
{298}
(#764931@0)
-
why the PK in order_item_table is not(order_id,book_id)? and why no PK in order_table?
-kkkkkkkk(Toronto123);
2002-9-24
(#764995@0)
-
Are u DBA or Programmer?Thanks!
order_item_table
order_id, ---\ primary key
line_no, ---/
book_id, --foreign key
unit_price,
quantity,
sub_total,
this table seems should like this:
order_item_table
item_id---/primary key
order_id, ---\ foreign key
line_no, ---/
book_id, --foreign key
unit_price,
quantity,
sub_total,
-aaaaaaaa(aaaa);
2002-9-24
{328}
(#765020@0)
-
item_id实际没必要出现
-hugefox(长得象熊的狐狸);
2002-9-25
(#766622@0)
-
why? You mean order_id also can be the promary key for this table, how about one order different type of books
-aaaaaaaa(aaaa);
2002-10-3
(#780374@0)
-
当然是用lineno区分了,直观的将定单分成几行,每行成为1条记录
-hugefox(长得象熊的狐狸);
2002-10-12
(#795158@0)
-
这么可怜啊! 回锅过好日子吧!
-arthurxu(ArthurXu OCP8,9i);
2002-9-24
(#765022@0)
-
I donnt think so, we could try to find any possible opportunities.
-aaaaaaaa(aaaa);
2002-9-24
(#765025@0)
-
Using Erwin or powerdesign will help you a lots.搞不清楚你们是干什么的, er图工具都不用就想开发, 我看你们加个DBA吧.
顺便我找工作也多一个机会
-arthurxu(ArthurXu OCP8,9i);
2002-9-24
{92}
(#765033@0)
-
Can you souple people small company to spend money to buy some ERWIN tools, no money
-aaaaaaaa(aaaa);
2002-9-24
(#765045@0)
-
Hi, man! I'm a MCDBA and SCJP, may I have a chance to be a volunteer of your company? I do need CND exp.
-pants(花和尚叔叔);
2002-9-24
(#765054@0)
-
Do it like in china, download it. I have one
-arthurxu(ArthurXu OCP8,9i);
2002-9-24
(#765421@0)
-
估计人家连电话区号都不愿提供的。
-easyway(翠花,回家吧!);
2002-9-24
(#765454@0)
-
没见人家只是junior吗?
-westwood(西木头);
2002-10-4
(#781161@0)
-
Look here:Order:
Order_ID | Date | Customer | ......
Books:
Book_ID | Author | Price .......
BookOrder: (Association table)
Order_ID | Book_ID | Quantity
-eggplant(老茄子);
2002-10-2
{154}
(#778863@0)
-
Does the bookorder needs a primarykey such as bookorder_id.
-aaaaaaaa(aaaa);
2002-10-3
(#780378@0)
-
我给你发了EMAIL,请查收邮件!
-mickeymouse(米老鼠);
2002-10-6
(#784964@0)
-
sql code 基本是erWin生成的, 设计是根据我的实际项目. 如果有online store的问题, feel free to ask. 我是做online store and CRM 系统的.
-anno(烦人);
2002-10-11
{3255}
(#792774@0)
-
这才是我说的软件开发,不懂得快学。。。
-arthurxu(ArthurXu OCP8,9i);
2002-10-12
(#794572@0)
-
很佩服,您真的是online store的设计者吗?但是有几个地方看不太明白
第一就是为什么在T_OrderItem 的Book_id的foriegn Key上有On DELETE CASCADE,因为我们以前的做法都是当有顾客已经下了定单定了某些书以后,这些书的记录就不能再被删除了。
再有就是当book却货或者已经不卖了的时候,是把它们的记录直接删除吗,为什么没有book的status呢
还有后面的几个trigger,看得出您这里的Book_id和Order_id都是可以改的啊。但是那两个after delete的有什么用呢,您都在那儿写了on delete cascade了
我是个经验比较短的developer而已,向您请教了
-hugefox(长得象熊的狐狸);
2002-10-12
{465}
(#794914@0)
-
这还差不多。
-miketany(MIKE老狼);
2002-10-12
(#795149@0)
-
查不多是什么?答案是什么?
-hugefox(长得象熊的狐狸);
2002-10-12
(#795160@0)
-
我觉得没什么正确答案,但这样的做法似乎更实际一些。应该加一些状态到是真的,如果数据记录出了错,可以让DBA去改,使用trigger似乎太冒进了些
-miketany(MIKE老狼);
2002-10-13
(#795767@0)
-
数据库是主要保证数据有效存储和读取的,完成的主要是数据层,你的问题主要是业务层的,主要应该有程序代码实现,当然数据库的约束和trigger要配合啦!数据-业务-表现,这样才是好的系统设计
-arthurxu(ArthurXu OCP8,9i);
2002-10-13
(#795473@0)
-
还是有不明白的地方大家都是干程序员的,所以技术上的事情可以放开了说,您不必担心我不懂
我的第一、二个问题就是关于完整性的,你今天加了本书到网站上,顾客订了,你还可以把这本书的记录删掉,连带顾客的定单上的一条删掉吗?我不敢。
最后的问题不是问trigger是干什么用的,我还看得懂一点点。我只是想问,那两个trigger明明没有用,为什么还要加上去。
整个的3个问题里没有一个涉及业务层的啊,我只是想学学前辈们的更先进的做法。
-hugefox(长得象熊的狐狸);
2002-10-13
{391}
(#795648@0)
-
我说了, SQL 基本是erWin生成的, 实际上, 我的系统里极少使用trigger, 只有在前台无法控制或前后台都有数据操作时才考虑.
-anno(烦人);
2002-10-15
{575}
(#798450@0)
-
Trigger is a trouble for a online system under tons of transaction.
-kkkkkkkk(Toronto123);
2002-10-16
(#800832@0)
-
天哪, 和天书一样啊, :)
-dropoutinmiami(东北的饺子);
2002-10-12
(#794919@0)