正确的 MySQL 数据库结构

发布于 2024-10-31 09:43:50 字数 659 浏览 2 评论 0原文

我正在为当地餐馆目录开发一个网络管理面板。他们的旧系统非常笨重,如果不修改一堆代码就无法扩展。

当前的数据库结构如下:

table: Restaurants
cols: id, restname, preferred, image, phone, address, website, vip_special

该表就列而言是静态的。

table: Locations
cols: id, restname, downtown, bluffton, tybee, pooler, etc...

table: Cuisines
cols: id, restname, american, chinese, seafood, bar_tavern, etc...

table: Ambiances
cols: id, restname, outdoor_dining, fine_dining, waterfront, rooftop, romantic, etc...

后 3 个表要求开发人员进入并为每个新位置、美食或氛围添加一个新列,并更改代码以反映这些新列。

在 DBA 方面,我并不是最优秀的,所以我很好奇对于这种情况最好的结构是什么。

关联:一家餐厅可以有多个地点、菜肴和氛围,

谢谢大家的帮助。

I'm developing a web administration panel for a local restaurant directory. Their old system is very clunky and not able to expand without modifying a bunch of code.

The current DB structure is like this:

table: Restaurants
cols: id, restname, preferred, image, phone, address, website, vip_special

This table is static as far as columns go.

table: Locations
cols: id, restname, downtown, bluffton, tybee, pooler, etc...

table: Cuisines
cols: id, restname, american, chinese, seafood, bar_tavern, etc...

table: Ambiances
cols: id, restname, outdoor_dining, fine_dining, waterfront, rooftop, romantic, etc...

The latter 3 tables require a developer to go in and add a new column for each new location, cuisine, or ambiance as well as change the code to reflect those new columns.

I'm not the greatest when it comes to DBA so I was curious as to what the best structure would be to this situation.

Associations: A restaurant can have several locations, cuisines, and ambiances

Thank you all for the help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

傻比既视感 2024-11-07 09:43:50

这里的起始

restaurant
restaurant_id | restaurant_nm | everything that a restaurant has exactly one of

tag_restaurant_rel
restaurant_id | tag_id

tag
tag_id | tag_type(_id) | tag_nm

tag_type
tag_type_id | tag_nm

标签类型可以是枚举,如果您有一些不会改变的类型,您可以删除类型表。
我不确定您是否想将一家餐厅分配到多个地点,因为即使它们可能是连锁店,氛围也可能会有所不同,菜单可能会提供不同的美食

Here's a start

restaurant
restaurant_id | restaurant_nm | everything that a restaurant has exactly one of

tag_restaurant_rel
restaurant_id | tag_id

tag
tag_id | tag_type(_id) | tag_nm

tag_type
tag_type_id | tag_nm

Tag type could be an enum if you have a few types that won't change you can drop the type table.
I'm not sure if you want to assign one restaurant multiple locations as, even though they might be a chain, the ambiance might be different and the menu might offer different cuisines

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文