How would I make a user database for an iPhone application? - ios

I am relatively new to iOS development and part of the application I'm developing requires a database of users which holds information about each user. Is there a tutorial out there that can show me how to create a database and link it with my iOS app? If not any sort of explanation would work.

First, if you want a DB to connect to, you'd need 2 things: A DB server and a Webserver to open it through webservices. Since you are new, I'd suggest you set up a LAMP server (Linux, Apache, MySQL, PHP) or a WAMP server (Windows, Apache, MySQL, PHP).
For WAMP and LAMP, I suggest you install each module separately but there are packages with contains the all the modules.
http://tenfouragency.com/setting-up-a-wamp-local-server-on-windows-7/
First, you'd need to create the DB in MySQL: https://dev.mysql.com/doc/refman/5.1/en/database-use.html
Second, you'd need to open it through webservices in Php: https://web.stanford.edu/dept/its/communications/webservices/wiki/index.php/How_to_connect_to_a_MySQL_database_with_PHP
Third, you would need call your webservices through the app: http://blog.strikeiron.com/bid/63338/Integrate-a-REST-API-into-an-iPhone-App-in-less-than-15-minutes
This is a fairly big endeavour for someone that's just starting out so I'd advise you just do these things one step at a time. This is also a very basic overview so I suggest you use the terms and concepts I use (such as webservices) to further your own research into these topics.

Related

MySQL server and iOS app

I am running a site right now with a quite big MySQL database.
Now, I want to create an app. I will need to use obviously a database de to the fact my data are already there.
Thus,
1) Should I keep using the MySQL server and my iOS app will connect to this MySQL serve for getting data?
2) is there any problem if I use the MySQL server ? Security issues maybe?
3) if I have to change the MySQL server, what database infrastructure I need to build and work with?
I am totally newbie on iOS apps. And now I planning to face any issues my iOS app will have.
Since you are running a site with MySQL I think a lot of your questions have been answered. You already have seen how your MySQL database performs in a production environment. Unless you believe that your iOS user base is going to be much larger or perform very different functions you currently have valid performance benchmarks.
In terms of how it relates to the iOS app, you can build an API, or make calls to https pages on your website that will return the information required for your app. For information on how to do this, check out this AFNetworking tutorial.
In the end, there might be some reasons that your current database isn't the right choice for your app. But since the app won't be interacting directly with the database, you can change it out later and you will only have to integrate the database with the interface and not change the iOS app at all.

Communication between Rails apps

I have built two rails apps that need to communicate and send files between each other. For example one rails app would send a request to view a table in the other apps' database. The other app would then render json of that table and send it back. I would also like one app to send a text file stored in its public directory to the other app's public directory.
I have never done anything like this so I don't even know where to begin. Any help would be appreciated. Thanks!
You requirement is common for almost all the web apps irrespective of rails, Communicating with each other is required by most modern web apps. But there is a small understanding that you need to get hold on,
Web sites should not directly access each others internal data (such as tables), (even if they are build by the same language (in this case Rails) by the same developer),
That is where the web-services comes in to play, So you should expose your data through web services so that not only rails application can consume that, but also any app that knows how to consume a web service will get benefit.
Coming back to your question with Rails, rails supports REST web services out of the box, So do some googling about web services, REST web services with rails
HTH
As a starting point, look at ActiveResource.
Railscast
docs
Message queuing systems such as RabbitMQ may be used to communicate things internally between different apps such as a "mailer" app and a main "hub" application.
Alternatively, you can use a shared connection to something like redis stick things onto a "queue" in one app and read them for processing from the other.
In recent Rails versions, it is rather easy to develop API only applications. In the Rails core master, there was even a special application type for these apps briefly (until it got yanked again). But it is still available as a plugin and probably one day becomes actually part of Rails core again. See http://blog.wyeworks.com/2012/4/20/rails-for-api-applications-rails-api-released for more information.
To actually develop and maintain the API of the backend service and make sure both backend and frontend have the same understanding of the resources, you can use ROAR which is great way to build great APIs.
Generally, you should fully define your backend application with an API. Trying to be clever and to skip some of the design steps will only bring you headaches in the long run...
Check out Morpheus. It lets you create RESTful services and use familiar ActiveRecord syntax in the client.

Linking Cocoa desktop app & RubyonRails website

I'm developing a tool that will comprise a central website and a desktop application. I've only really done entirely online developent, or entirely offline/client-side development before and not really had to link the two. I could use some help in how to approach passing data to/from the online site & desktop app.
The desktop app needs to communicate & do some control of iTunes, so initially I'm building this in Cocoa on OSX & making use of the ScriptingBridge framework.
On the website side I'm thinking of using Ruby on Rails, with data stored in a mySQL database, as I'm fairly familiar & seems like a good match for the online job it has to do. (But open to other suggestions if there's a better approach!)
I'm struggling to find the best approach to easily transfer data between the Cocoa app & the online rails database - is there a simple way of having the Cocoa app access the online database directly, or is it typical to dump some XML onto the webserver and have the app read that?
Opening a RESTful API on your RoR system is as simple as you can get. Have your desktop app communicate with that API using JSON or XML.
Advantages to using JSON rather than XML: (1) extremely simple to manipulate in Rails (2) extremely simple to work with in Javascript, should the need arise to build a web client in addition to the desktop one.
It's a very bad idea to have the desktop app communicate directly with your remote database. Two main reasons:
Security. Such a setup just begs to be hacked. Some databases are "built for the web" (CouchDB comes to mind) and would be alright here, but MySQL isn't.
Flexibility. With desktop application in the field, making changes and distributing them to all clients is hard. Should the need arise to change your schema, the web application layer frequently allows you to keep the interface with the desktop clients stable.

iOS Web Database

I need to populate a table in an iOS application with data from a Web database
I already have a MySQL database set up but reading about this it seems there must be an easier way for the iOS to interact with a web database
Any help or pointers would be appreciated,
Thanks
You should make an API interface.
Then use the API to communicate with the database. Using the database directly is a very bad thing to do.
If you are really desperate, consider using the MySQL C library. This article explains it in great detail:
http://www.karlkraft.com/index.php/2010/09/17/mysql-for-iphone-and-osx/
For my application, I chose to create a web service to act as an intermediary between my application and the database.
This layout has several advantages. Considering you have MySQL database you can try to create some php scripts (I chose php because the API to work with mysql is very very simple and as you said, you don't need very high security or performance).
You can use these scripts through HTTP requests (you can use NSURLConnection to do these).. These scripts connect to mysql , fetch the data you need to pass the result back to the application in an easier to use format (e.g. I use JSON).

What databases should I use with Ruby on Rails, based on current Hosting services?

I've been looking for hosting services and I still don't know what kind of database is the most commom. It seems to be MySql and PostgreSql.
So, I'm not sure about how much traffic and data my website will have (it's just a project), but I would like to be prepared. I've worked in some projects with Oracle (PL/SQL) and I know something from MySql.
Thank you !
ps. 4 years later, I've been coding RoR mostly with PostgreSQL. SQLite by default when I need simple apps, but PostgreSQL otherwise.
One of the tenets of Rails is you shouldn't really care what database you're using: that's all abstracted for you.
So I would say go with the hosting provider that seems the overall best, and trust them to pick a good database.
In this case, as house9, I would recommend Heroku as an excellent overall service. Start with a small, free plan, scale up as needed. They use PostgreSQL by default, which has been entirely adequate in my experience.
I recommend Heroku for hosting
they require Postgres or if you want to go 'NoSql' - you can use MongoDB via the MongoHQ Heroku plug-in
http://heroku.com/
they offer a 'free' plan for small sites
Engine Yard is a trusted Rails host. They support MySQL, Postgres and MongoDB. Here is their list of supported technologies:
http://www.engineyard.com/technology/stack
On May 10th, they are hosting a demo on their cloud services.
MySQL is by far the most common free web database now a days, and is very common in Ruby on Rails Projects. Almost all linux hosting providers will give you mysql databases. Unless you have a specific reason to go elsewhere, it is a great place to start.
I have personally implemented a couple of RoR projects that used MySQL as the backend with no complaints.
I don't think there is any argument that MySQL is the most used. If you re looking for an enterprise class database, I say give DB2 a try. Just like MySQL, DB2 Express-C is free and optional support is available. DB2 is the only database that has support from the vendor. See http://antoniocangiano.com/2010/04/22/rails-db2-and-the-enterprise/.

Resources