数据库结构指南

Guidance for database structure

我对这一切都很陌生。假设我想为世界各地的各种厨师制作一个网站(可能是大量数据)。在我的索引页面上,它会列出个人 "posts" 展示厨师和他们的 2 或 3 种特色菜肴。

chefstable [id, chef_name]

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

单击此 link 后,将加载一个新页面,其中包含更详细的视图,包括上述 + 每道菜的成分以及每种成分的单独成本。

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

将其中一些数据合并为一个 table 是否更可行,或者它们是否可以分成不同的 table,我将 link 放在一起。有没有人对更好的方法有想法?

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

我会采用这种结构:

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