douhe4608 2013-02-19 12:23
浏览 29

在这种情况下正确的mysql表设计/关系

I have this situation where i need suggestions on database tables design.

BACKGROUND

I am developing an application in PHP ( cakephp to be precise ). where we upload an xml file, it parses the file and save data in databases. These XML could be files or url feeds and these are purchased from various suppliers for data. It is intended to collect various venues data from source urls , venues can be anything like hotels , cinemas , schools , restaurants etc.

Problem

Initial table structure for these venues is as below . table is deigned to store generic information initially.

id
Address
Postcode
Lat
Long
SourceURL
Source
Type
Phone
Email
Website

With the more data coming from different sources , I realized that there are many attributes for different types of venues.

For example a hotel can have some attributes like

price_for_one_day, types_of_accommodation, Number_of_rooms etc

where as schools will not have them but have different set of attributes.Restaurant will have some other attributes.

My first idea is to create two tables called vanue_attribute_names , Venue_attributes

##table venue_attribute_names
_____________________________
id
name

##table venue_attributes
________________________
id
venue_id
venue_attribute_name_id
value

So if I detect any new attribute I want to create one and the its value in attributes table with a relation. But I doubt this is not the correct approach. I believe there could be any other approach for this?. Besides if table grows huge there could be performance issues because of increase in joins and also sql queries

Is creating widest possible table with all possible attributes as columns is right approach? Please let me know. If there any links where I could refer I can follow it . Thanks

  • 写回答

2条回答 默认 最新

  • doufeng9567 2013-02-19 12:32
    关注

    If you are sticking with a relational data base, that's it. The options you listed are pretty much what they can give you.

    For your situation MongoDB (or an other document oriented NoSql system) could be a good option. This db systems are very good if your have a lot of records with different atributes.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据