开发者

mysql----how to design this database?

vegetable attributes:

  • the name of开发者_如何学Python the vegetable (v_name)
  • the producer name of the vegetable (p_name)
  • the address of the producer (p_addr)
  • producer phone (p_phone)
  • production time (p_time)
  • vegetable price (v_price)
  • vegetable intro (v_intro)
  • vegetable type (v_type); it have spring vegetable and winter vegetable.

the above is the fields of the database, now, how to design this database. thank you.

the needs of the database: according to the producer name , which can list all of the vegetables that under it.


I think, some more info on constraints would help design database better.
With given info, I can think of following design:

vegetables:

v_id (primary key)
v_name
v_price
v_intro
v_type_id

vegetable_type:

v_type_id (primary key)
v_type

producers:

p_id (primary key)
p_name
p_addr
p_phone
p_time

vegetable_producers:

p_id (primary key)
v_id primary key)

More clarity is needed for vegetable production time, if its dependent on producer or vegetable.

Query can be designed to retrieve necessary details from the database by providing the respective primary key/s and fields.


Well that can be a design. You can normalize it by creating three tables:

Vegetables(id,name,price,intro,typeId,producerId,productionTime)
VegetableType(id,type)
Producers(id,addr,phone)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜