2015-04-15 36 views
-1

我对这一切都很陌生。假设我想为世界各地的厨师建立一个网站(可能是大量的数据收集)。在我的索引页上,它会列出显示厨师和其中2或3种特色菜肴的个人"posts"数据库结构指南

chefstable [id, chef_name] 

dishtable [id, chef_id(foreign key), dish1, dish2, dish3(nullable)] 

在点击该链接时,一个新的页面将与更详细的视图加载,包括每个菜和个人成本每种成分以上+成分。

ingredientstable [id, dish_id(foreign key), ingredient1, ingredient2, ingredient3, ingredient4...(`nullable`), ingredient1cost, ingredient2cost, ingredient3cost...(nullable)] 

难道是比较可行的巩固某些数据到一个表,或者他们确定分成不同的表,我会链接在一起。有没有人有更好的方式有想法?

我很担心这个结构,因为会有很多null的值(菜肴会有不同数量的配料)。 任何指导将不胜感激。

回答

1

我会去与这种结构:

chefs 

id 
chef_name 

-- 

dishes 

id 
chef_id FK 
dish_type_id (1,2 or 3) 
value 

-- 

ingredients 

id 
dish_id FK 
ingredient_id (1,2,3 or 4) 
ingredient_cost 
value 
+0

非常感谢你@Mex –