简体   繁体   English

对于旧的数据库结构,更好的数据库设计是什么?

[英]What would be the Better db design for the old db structure?

i've a old database where i store the data of the holidays and dates in which they are celebrated.. 我有一个旧的数据库,我在那里存储假期和庆祝日期的数据。

id  country     hdate           description     link 
1   Afghanistan     2008-01-19  Ashura          ashura
2       Albania     2008-01-01  New Year Day    new-year

the flaws in the above structure is that, i repeat the data other than date for every festival and every year and every country.. 上述结构的缺点是,我针对每个节日,每年和每个国家/地区重复日期以外的数据。

For example, I store a new date for 2009 for ashura and afghanistan .. 例如,我为阿修罗和阿富汗存储了2009年的新日期。

I tried to limit the redundancy and split the tables as 我试图限制冗余并将表拆分为

countries (id,name)

holidays (id, holiday, celebrated_by, link) 
// celebrated_by will store the id's of countries separated by ','

holiday_dates (holiday_id, date, year) 
// date will the full date and year will be as 2008 or 2009

Now i have some problems with the structure too.. 现在我的结构也有一些问题。

consider that i store the holiday like Independence day , its common for more countries but will have different dates. 考虑到我将假期存储为独立日,这对于更多国家/地区来说是很常见的,但日期却不同。 so how to handle this and and the link will have to be different too. 因此如何处理该问题,链接也必须有所不同。 .

And i need to list the countries which celebrates the same holiday and also when i describe about a single holiday i need to list all the other holidays that country would be celebrating.. 而且我需要列出庆祝同一假期的国家,并且当我描述一个假期时,我需要列出该国将庆祝的所有其他假期。

And the most of all , i already have huge amount of data in the old tables and i need to split it to the new one once the new design is finalized... 最重要的是,我已经在旧表中存储了大量数据,一旦完成新设计,我需要将其拆分为新数据。

Any ideas? 有任何想法吗?

What about having a nn relationship? 拥有nn关系怎么样?

Table: Country 表:国家

  • Country_ID (PK) Country_ID(PK)

Table: CountryToHoliday 表格:CountryToHoliday

  • Country_ID (FK) Country_ID(FK)
  • Holiday_ID (FK) 假日编号(FK)

Table: Holiday 表:假期

  • Holiday_ID (PK) 假日编号(PK)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 这个DB设计是否可以接受,还是有更好的方法? - Is this DB design acceptable, or is there a better way? mysql db结构以获得更好的性能 - mysql db structure for better performance 数据库基础电子邮件系统的最佳数据库设计是什么? - what would be a good db design for database base email system? 多语言目录(带有自定义字段)数据库结构设计 - Multilang catalog(with custom fields) DB structure design MySql数据库设计-哪种表结构更好? - MySql database design - which table structure would be better? 用rails更好地将geoip资源保存在同一数据库或分离的数据库中? - rails what is better to save geoip resources in same db or in separated db? MySql:使用'view'是合理的还是我会更好地对我的数据库进行非规范化? - MySql: Is it reasonable to use 'view' or I would better denormalize my DB? 数据库中正确的垃圾回收机制是什么? - What would be the proper garbage collection mechanism in a DB? 什么是最佳的数据库缓存用于此应用程序? - What would be the best DB cache to use for this application? SQL查询-选择组中的“上次更新”记录,更好的数据库设计? - SQL query - choosing 'last updated' record in a group, better db design?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM