将MySQL数据库导出到CouchDB的最简单的方法? [英] Easiest way to export a MySQL database to CouchDB?

查看:202
本文介绍了将MySQL数据库导出到CouchDB的最简单的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想通过重写一个非常简单的MySQL和PHP应用程序来玩NOSQL和Node.js,以便学生可以向教授发表评论:

I'm just looking to play around with NOSQL and Node.js by re-writing a very simple MySQL and PHP app so students can leave comments to professors:

Table: Prof
Columns: id, first, last, university, department

Table: Comments
Columns: id, user_id, likes, data

这个关系基本上是一位教授有很多评论和评论属于一位教授。

The relationship is basically a Professor has many Comments and a Comment belongs to one Professor.

我认为CouchDB / JSON版本将如下所示:

I think the CouchDB/JSON version would look like this:

{ "Profs" : [{
  "Comments" : [ {"data" : "comment1", "likes" : 42 } , { "data" : "comment2", "likes" : 1} ],
 "first" : "Carlos",
 "last" : "Marx",
 "university" : "some university",
 "department" : "math"
}, {...another prof with comments...}], 
 }

我的第一个问题是,有没有可以运行的工具或脚本将我的所有数据导入CouchDB可以工作的东西?如果没有,你会推荐什么?我可以从phpmyadmin将其导出为.sql和.cvs。

My first question is, is there a tool or script I can run to import all of my data into something CouchDB can work? If not, what would you recommend? I can export it to .sql and .cvs from phpmyadmin.

我的第二个问题是我在JSON中正确构建了我的数据?

My second question is did I correctly structure my data in JSON?

谢谢!

推荐答案

MySQL数据库到CouchDB或任何其他NoSQL数据库。它们是不同的范例,需要改变你对数据存储方式的思考。对于关系数据库和文档数据库都有很好的用例,而且有很多重叠,它们都在不同的东西上表现出来。

You really don't just export a MySQL database to CouchDB or any other NoSQL database. They are different paradigms and require changing the way you think about how your data is stored. There are excellent use cases for both relational and document databases, and while there is a lot of overlap, they both excel at different things.

使用NoSQL数据库,重要的是要了解您的数据将如何使用。应用程序如何编写和使用数据,如果数据经常更新,则会对如何设计文档有非常重要的影响。在你的例子中。你可以编辑评论吗?如何评论评论?你总是显示所有的,还是想要结果被分页?添加评论的频率?他们可以被删除吗?不知道这些问题的答案,我不能肯定,CouchDB是否是正确的NoSQL解决方案的问题!

With NoSQL databases, it is very important to understand how your data is going to be used. How data is written and used by your application and if data is frequently updated all have very important effects on how you should design your documents. In your example for instance. Can you edit comments? How are comments viewed? Do you always show all of them or do you want the results to be paged? How frequently are comments added? Can they be removed? Without knowing the answers to some of these questions, I can't say for certain whether CouchDB is even the right NoSQL solution for the problem!

我很抱歉,这是一个非直接的答案,您的问题,但接近从关系数据库迁移到NoSQL解决方案作为一个简单的地图从表到集合是一个失败的秘诀。一旦你花了时间来设计你的文档在CouchDB中的外观,数据就必须经过一个转换过程。这可以采取许多形状。您可以编写一个可从MySQL读取并写入CouchDB的应用程序,也可以导出为其他格式,并具有脚本导入。没有什么魔法按钮可以让您的MySQL数据库变成一个沙发数据库,​​如果有的话,由于上述问题,真的不应该存在。

I'm sorry that this is sort of a non-direct answer to your question, but approaching a migration from a relational database to a NoSQL solution as a simple map from tables to collections is a recipe for failure. Once you have put the time into designing how your documents should look in CouchDB, the data will have to go through a transformation process. That can take many shapes. You could write an application that can read from MySQL and write to CouchDB or you can export to some other format and have a script import that. There is no magic button that will take your MySQL database and turn it into a Couch database, and if there is, it really should not exist due to the issues mentioned above.

这篇关于将MySQL数据库导出到CouchDB的最简单的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆