Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ArtOfWarfare

macrumors G3
Original poster
Nov 26, 2007
9,555
6,053
I'd like to set up a database with an API that other developers can use to make apps that can view and modify my database.

I'd like to keep my costs at a minimum.

I'd like to control the developers accessing my database, the apps accessing my database, and the end users accessing my database.

I want to ensure that the database is secure and restrict the modifications that can be made to my database - IE, I'd like to make sure that people don't add things to my database that don't belong, and I'd like to ensure that people don't add incomplete entries to my database, and I'd like to make sure that people don't delete entries such that they render other data illogical.

I have no experience with setting up a server or online database (although I have some experience with SQL/MySQL Workbench.) I was hoping people could answer these questions for me:

1 - Do I need to write my own server side code to do everything, or is there something magical I can do that allows me to avoid writing my own server side code?

Skip 1a and 1b if I don't need to write my own server side code...

1a - What language(s) should I use for my server side code? I know C, C++, Obj-C, Obj-C++, Java, JavaScript, and SQL. I've got nothing against learning more languages, I just provide that list so you might know which language would be easiest for me to learn for this.

1b - Are there hosting services where I can upload this server side code?

2 - I have a few old Macs laying around the house (a Mac Mini, a G4 tower, and a G5 tower,) that I feel I could use to host this database. Should I use them or some other hosting service? If I should use them, how would I go about doing so?

Thanks in advance! (This all pertains to the same topic as one that I had in iOS Programming yesterday, but I feel like the questions I wrote here have a much different approach to the root of the things I want done in my iOS app.)
 

wedgeantilles

macrumors newbie
Apr 23, 2013
7
0
The easiest way of hosting a database and associated API is to use the AWS Free Tier. This gives you access to enough free hours to run a Micro EC2 instance to host your code and free usage of a SQL/NoSQL database depending on your requirements.

AWS offers a choice of databases, but if you don't like any of their options, you can always install and run your own on EC2 instead of using one of the on-demand options.

As for your questions about how to control access to the database, you've already answered this in terms of discussing an API. The key in writing an API is to expose a series of functions and methods via the API that developers can use in their own applications to request changes to your data.

You are then able to sanitise requests and use your own logic to transform API requests into actionable changes on the database - but you control the logic and access to allow this to happen.

I.E. You write an API function that allows users to pass through data to update a record in the database. As you control the API and the methods you're exposing, no-one else has access to the underlying code that actually makes the change - they only see and can only call the API functions.

Regarding the choice of language, this is partially a personal preference and partially down to what you want your users to use. JSON is popular right now, so would be worth taking a look at.
 

ArtOfWarfare

macrumors G3
Original poster
Nov 26, 2007
9,555
6,053
The easiest way of hosting a database and associated API is to use the AWS Free Tier. This gives you access to enough free hours to run a Micro EC2 instance to host your code and free usage of a SQL/NoSQL database depending on your requirements.

AWS offers a choice of databases, but if you don't like any of their options, you can always install and run your own on EC2 instead of using one of the on-demand options.

As for your questions about how to control access to the database, you've already answered this in terms of discussing an API. The key in writing an API is to expose a series of functions and methods via the API that developers can use in their own applications to request changes to your data.

You are then able to sanitise requests and use your own logic to transform API requests into actionable changes on the database - but you control the logic and access to allow this to happen.

I.E. You write an API function that allows users to pass through data to update a record in the database. As you control the API and the methods you're exposing, no-one else has access to the underlying code that actually makes the change - they only see and can only call the API functions.

Regarding the choice of language, this is partially a personal preference and partially down to what you want your users to use. JSON is popular right now, so would be worth taking a look at.

I looked into AWS and it looks to me like it was just a data storage service - it seemed like apps are expected to send raw CRUD commands which would allow users to maliciously change my database. But if you think I can add my own server side code to it, I guess I'll keep looking at it.
 

Ap0ks

macrumors 6502
Aug 12, 2008
316
93
Cambridge, UK
You'll want a free tier instance of AWS RDS (relational database) or DynamoDB (NoSQL) and then a free tier instance of EC2 to run the API code for the database.

You can use most languages, but it really depends on what you want to do and the purpose of the database. Languages popular for Web/API projects at the moment include Ruby/Rails, Python, NodeJS or you can go for one of the bigger solutions PHP, .Net or Java.

There's bound to be plenty of frameworks for each language too should you not want to code the whole thing by hand ;)
 

ArtOfWarfare

macrumors G3
Original poster
Nov 26, 2007
9,555
6,053
You'll want a free tier instance of AWS RDS (relational database) or DynamoDB (NoSQL) and then a free tier instance of EC2 to run the API code for the database.

Thanks for that! I had just been looking at their database services and was scratching my head about how I could define any sort of API using that. I'll have to look at EC2 and decide whether I want to use an RDB or NoSQL... I'm leaning towards NoSQL even though I know nothing about it just because I've heard it's less limited than an RDB and scales better...

Edit: EC2 seems to completely lack a free tier... I really don't want to have any chance of being changed any money when I'm just testing this stuff out...
 
Last edited:

Ap0ks

macrumors 6502
Aug 12, 2008
316
93
Cambridge, UK
Thanks for that! I had just been looking at their database services and was scratching my head about how I could define any sort of API using that. I'll have to look at EC2 and decide whether I want to use an RDB or NoSQL... I'm leaning towards NoSQL even though I know nothing about it just because I've heard it's less limited than an RDB and scales better...

Edit: EC2 seems to completely lack a free tier... I really don't want to have any chance of being changed any money when I'm just testing this stuff out...
It is there, similar to the RDS and DynamoDB free tiers you get 750 hours a month of a Linux or Windows micro instance for nothing. However one thing to note is that the free tier only lasts for 12 months, so if your project is going to run longer than that you'll end up having to pay standard rates.

As for NoSQL vs RDB it does depend on what you're going to be storing and what you'll be doing with the data.
 

brohan711

macrumors newbie
Apr 10, 2012
22
30
Parse?

Are you talking about a service like parse which has a simple api and free for basic services (Which go a long way btw). They use a mongodb which uses javascript. Check out both parse and mongodb!
 

Ap0ks

macrumors 6502
Aug 12, 2008
316
93
Cambridge, UK
Are you talking about a service like parse which has a simple api and free for basic services (Which go a long way btw). They use a mongodb which uses javascript. Check out both parse and mongodb!
That Parse service does look pretty useful, thanks for bringing it to light :)
 

ArtOfWarfare

macrumors G3
Original poster
Nov 26, 2007
9,555
6,053
Are you talking about a service like parse which has a simple api and free for basic services (Which go a long way btw). They use a mongodb which uses javascript. Check out both parse and mongodb!

Hmmm... it looks promising. It looks vastly more straight forward than Amazon's services, and I managed to sign up for it in 3 button clicks ("Sign Up" -> "Use Facebook" -> (On Facebook) "Approve")... whereas signing up for Amazon involved getting an automated phone call and typing in codes and giving them my credit card information...

The only drawback is it goes from free to $200/month with nothing in between. Hopefully the free is adequate for me, because right now my plans are to offer my app and service for free (without so much as ads initially) with the idea of turning it into a revenue source if it turns out that I end up with a lot of users loving it and willing to pay a small fee...
 

brohan711

macrumors newbie
Apr 10, 2012
22
30
Hmmm... it looks promising. It looks vastly more straight forward than Amazon's services, and I managed to sign up for it in 3 button clicks ("Sign Up" -> "Use Facebook" -> (On Facebook) "Approve")... whereas signing up for Amazon involved getting an automated phone call and typing in codes and giving them my credit card information...

The only drawback is it goes from free to $200/month with nothing in between. Hopefully the free is adequate for me, because right now my plans are to offer my app and service for free (without so much as ads initially) with the idea of turning it into a revenue source if it turns out that I end up with a lot of users loving it and willing to pay a small fee...


They do offer 7 cents /1000 Api requests and push notifications you go over the original 1million. So if you do go over you don't have to pay THAT much. Although i haven't reached the level of scalability to actually analyze the costs in a real situation.

And no problem. It is a great service. I use it for all of my applications i make for iOS. The API is PHENOMENAL. I haven't had one issue with it except integration with facebook into the applications. But Facebook just acquired it so who knows??
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.