doomm4711 2011-07-31 19:10
浏览 14

连接这样的两个数据库是一个坏主意吗? 怎么做到呢?

I am currently using Simple Machines Forum on my website, and users both register AND login using their forum account on my website. The smf_members table contains fields such as:

id_member | member_name | date_registered

What I am trying to do now is extend this to add more custom fields and connectivity on my site. I want to use the id_member field for many things:

For example, I want a user (an entry in this smf_members table) to be able to join a team.

I am going to create a table Teams with the following fields:

ID | Name | Description

and a table TeamMembership with the following fields:

UserID | TeamID | Role

As you can see, this table will link a member and a team, while leaving data specific to a user or team in their respective tables ONLY (successfully preventing redundant data). This sounds good, right?

Well, I don't want those two new tables in the same database as the SMF stuff, because it may get messy. Is it the easiest solution, though? Do you think the easiest solution is to just create my new tables within the same database, with the prefix cst for Custom? I have no idea how to link two databases so if it is too complicated maybe I should just do my cst solution.

I've edited this post and have an additional question.

Thank you for the answers. I have an additional question. Let's say that I wanted to extend new variables to the members, but again, wanted to avoid adding new fields into the SMF forum member table. What is the easiest way about going about this? Like, I want to create a table called UsersExtended and have fields such as:

-ID (this is NOT an auto-increment field, but the value of id_member from the SMF members table)

-Country

Is it easy to create a profile page with this structure and display any relevant data I want from the two tables, in a way, Linking the two so that they act as one big table?

  • 写回答

6条回答 默认 最新

  • doulu7174 2011-07-31 19:13
    关注

    They totally belong in the same database. Use one db and join the tables in your queries.

    The only time you want to build a unique database for your application (other than for the application itself) is if you intend to create an API which will serve up that data to other projects in an unbiased manner. That is very common with Solr in which you can churn out blazing fast API's and generally don't belong mixed in with your current MySQL tables.

    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么