alexkun4
alexkun4

Reputation: 105

creating a database for a website and mobile app

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 :)

Upvotes: 2

Views: 15503

Answers (4)

Harshal Doshi  Jain
Harshal Doshi Jain

Reputation: 2597

You need to use Service - Oriented Architecture.

You may use REST API methodology for creating interfaces.

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

Upvotes: -1

Boardy
Boardy

Reputation: 36205

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.

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.

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

Upvotes: 0

Rawkode
Rawkode

Reputation: 22592

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.

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.

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

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

Upvotes: 2

Christos Mitsis
Christos Mitsis

Reputation: 167

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

Upvotes: 0

Related Questions