为网站和移动应用程序创建数据库

时间:2022-11-30 11:28:13

I want to create a database so both my website and mobile app could draw info from there. I know how to execute queries with a website, but I have little to none experience with mobile applications. I heard I can't just use any form of database(mysql, mongodb) because they are not compatible or something. so how do I create my database so it will be compatible with android iOS and PC. A few guidelines to get me started would be great :)

我想创建一个数据库,所以我的网站和移动应用程序都可以从那里绘制信息。我知道如何使用网站执行查询,但我对移动应用程序几乎没有经验。我听说我不能只使用任何形式的数据库(mysql,mongodb),因为它们不兼容或什么的。所以我如何创建我的数据库,以便它与Android iOS和PC兼容。让我入门的一些指导方针会很棒:)

4 个解决方案

#1


2  

Sounds like you need to build an API to handle interaction between your mobile applications and your database, in much the same way your website communicates with your database. The primary difference will be that you will be returning JSON/XML to your apps, rather than displaying HTML to a user.

听起来你需要构建一个API来处理移动应用程序和数据库之间的交互,就像你的网站与数据库通信一样。主要区别在于您将JSON / XML返回到您的应用程序,而不是向用户显示HTML。

I thoroughly recommend JSON over XML as it is not as verbose and data usage will drop dramatically. However, if you're data structures are quite detailed / complex, go with XML.

我完全推荐JSON over XML,因为它不够冗长,数据使用量也会急剧下降。但是,如果您的数据结构非常详细/复杂,请使用XML。

To get started with building an API I'll recommend Slim PHP. You'll probably want some form of ORM also, for which I highly recommend idiorm/paris

要开始构建API,我建议使用Slim PHP。你可能也想要某种形式的ORM,我强烈推荐idiorm / paris

The documentation for both of these frameworks is great, so have a dig around.

这两个框架的文档都很棒,所以要深入研究。

#2


0  

You can create a database with MySQL and draw info from your site with mysql queries. As for your mobile app, you can use some php pages and JSON Parser to draw data from the database. See example

您可以使用MySQL创建数据库,并使用mysql查询从您的站点中提取信息。至于您的移动应用程序,您可以使用一些php页面和JSON Parser从数据库中绘制数据。见例子

#3


0  

As you say android doesn't support external databases such as MySQL. The easiest thing to do would be to create a MySQL Database that your website and android app can access.

正如你所说android不支持MySQL等外部数据库。最简单的方法是创建一个您的网站和Android应用程序可以访问的MySQL数据库。

The website would access the MySQL database as normal but the android app instead posts data such as variables to a PHP script, the PHP script can then get the retrieved data and perform the mysql queryies and json_encode the output and print the encoded data. The android app would then receive the outputted json format and the android app can then decode the json and process the data accordingly.

该网站将正常访问MySQL数据库,但Android应用程序将数据(如变量)发布到PHP脚本,然后PHP脚本可以获取检索到的数据并执行mysql查询并输出json_encode并打印编码数据。 Android应用程序然后将接收输出的json格式,然后android应用程序可以解码json并相应地处理数据。

http://www.helloandroid.com/tutorials/connecting-mysql-database has some tutorials on how this can be done

http://www.helloandroid.com/tutorials/connecting-mysql-database有一些关于如何做到这一点的教程

#4


0  

You need to use Service - Oriented Architecture.

您需要使用面向服务的体系结构。

You may use REST API methodology for creating interfaces.

您可以使用REST API方法来创建接口。

See this example www.hassanpur.com/blog/2010/09/android-development-implementing-a-simple-client-server-model/

请参阅此示例www.hassanpur.com/blog/2010/09/android-development-implementing-a-simple-client-server-model/

#1


2  

Sounds like you need to build an API to handle interaction between your mobile applications and your database, in much the same way your website communicates with your database. The primary difference will be that you will be returning JSON/XML to your apps, rather than displaying HTML to a user.

听起来你需要构建一个API来处理移动应用程序和数据库之间的交互,就像你的网站与数据库通信一样。主要区别在于您将JSON / XML返回到您的应用程序,而不是向用户显示HTML。

I thoroughly recommend JSON over XML as it is not as verbose and data usage will drop dramatically. However, if you're data structures are quite detailed / complex, go with XML.

我完全推荐JSON over XML,因为它不够冗长,数据使用量也会急剧下降。但是,如果您的数据结构非常详细/复杂,请使用XML。

To get started with building an API I'll recommend Slim PHP. You'll probably want some form of ORM also, for which I highly recommend idiorm/paris

要开始构建API,我建议使用Slim PHP。你可能也想要某种形式的ORM,我强烈推荐idiorm / paris

The documentation for both of these frameworks is great, so have a dig around.

这两个框架的文档都很棒,所以要深入研究。

#2


0  

You can create a database with MySQL and draw info from your site with mysql queries. As for your mobile app, you can use some php pages and JSON Parser to draw data from the database. See example

您可以使用MySQL创建数据库,并使用mysql查询从您的站点中提取信息。至于您的移动应用程序,您可以使用一些php页面和JSON Parser从数据库中绘制数据。见例子

#3


0  

As you say android doesn't support external databases such as MySQL. The easiest thing to do would be to create a MySQL Database that your website and android app can access.

正如你所说android不支持MySQL等外部数据库。最简单的方法是创建一个您的网站和Android应用程序可以访问的MySQL数据库。

The website would access the MySQL database as normal but the android app instead posts data such as variables to a PHP script, the PHP script can then get the retrieved data and perform the mysql queryies and json_encode the output and print the encoded data. The android app would then receive the outputted json format and the android app can then decode the json and process the data accordingly.

该网站将正常访问MySQL数据库,但Android应用程序将数据(如变量)发布到PHP脚本,然后PHP脚本可以获取检索到的数据并执行mysql查询并输出json_encode并打印编码数据。 Android应用程序然后将接收输出的json格式,然后android应用程序可以解码json并相应地处理数据。

http://www.helloandroid.com/tutorials/connecting-mysql-database has some tutorials on how this can be done

http://www.helloandroid.com/tutorials/connecting-mysql-database有一些关于如何做到这一点的教程

#4


0  

You need to use Service - Oriented Architecture.

您需要使用面向服务的体系结构。

You may use REST API methodology for creating interfaces.

您可以使用REST API方法来创建接口。

See this example www.hassanpur.com/blog/2010/09/android-development-implementing-a-simple-client-server-model/

请参阅此示例www.hassanpur.com/blog/2010/09/android-development-implementing-a-simple-client-server-model/