When Do We Need A Database For Our App?

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello welcome to this lesson where we're going to talk about different back-end options for your app so first of all what is the backend and why do you need one you may have noticed that a lot of the beginner tutorials on iOS you build simple stuff like calculators or maybe newsreaders or something like that and it's purely one-sided the user is only consuming content and not producing content and the reason why is that as soon as you get into the realm of user accounts or account management or producing content data that the user produces or that account that they created needs to be stored somewhere like that information that data it needs to exist somewhere so that's where we get into the backend territory where we need some sort of data store or database to hold that data and furthermore in the case of the user producing data that needs to be seen by other devices or other users it's not enough to store the data locally on the device you actually need to store the data somewhere that all of the different users can access that data so here are some examples where you would need to consider a back-end for your app so if you have some notion of user accounts whether that's logging in or creating an account or registering whether you have leaderboards if you have users posting or generating content if you're messaging other users if you're liking content you know you need to store that relationship somewhere or even if you want to implement the functionality where you sync data between different devices so if a user uses two different devices and you want to sync that data between those two devices for the same user you would still need a back-end so let's take a look at the diagram and see what this sort of setup looks like I mentioned a little bit about a server and a database but visually what does that look like so in this diagram we have two people client a and client B they're using the same app on their respective devices and we have a server so a server is usually a physical piece of hardware it may be a computer it may be well generally it is a computer that's specifically built to handle incoming requests from clients and then return the appropriate response so the server is a physical piece of hardware and a database is more of like it's not a physical thing but it's a way to store data in a organized and relevant format which makes it easy to query and return data or to populate data so a database is just a system of data management but the actual data is stored on hard disks in the server so for client a if the user is creating an account or generating some content or liking something or maybe they got a high score and you're posting it on the leader board climb a would send that data to the server as denoted by those arrows and then the server would store that data now climb be another user somewhere else using the same app when they send a request to that server to return let's say all the high scores or all of the latest messages or you know or different users that are on their friends list or whatever the server returns that data decline B which includes the data that client a just submitted to it so in this way you have multiple clients sending data to the server to store on the database and the server also retrieves and sends information back to the clients to display now this is a simplified example because in reality you probably have not just a single server but it'll be distributed between multiple servers but the idea is there so if you need to store data or sync data across different devices you're going to need to implement something like this following diagram this shows how an iOS app would interact with a traditional MySQL database and if you're not familiar with MySQL databases they're most often used with websites and web apps but whenever I teach iOS to be a nurse I get an overwhelming request for showing people how to interact with a MySQL database so this diagram illustrates how that would work the iOS app can't connect to the database directly instead you need to build additional server-side architecture which I have written there as web services which is essentially just code that sits in between the client and the server it handles the requests from the client and then interacts with the server or with the database I guess in this diagram it's not completely clear but the web services will connect to the database and then either query data for returning to the client or it will insert data into the database so the the iPhone app can connect to the database to do that directly and so you have to learn another programming language and build additional infrastructure just to interact with that MySQL database however this isn't the only option for a back-end for your app recognizing that people just want it to build apps not necessarily fumble around with server-side architecture and server-side code these things called a back-end as a service started cropping up and essentially what they do for you is remove away all of that complexity and just give you a set of web services to interact with so you don't even have to build the web services you don't have to set up your your database you don't have to worry about that database architecture all you need to do is send the data from your client to the web service and then query the data back what happens behind the scenes you don't have to worry about and to make it easier still a lot of these platforms have frameworks or SDKs that you can add into your Xcode project so you don't even need to create a request and send it to the web services all you need to do is stay in Xcode and read there the platform documentation on how to save data and how to retrieve data so what are some of the advantages for using these platforms or backends as a service well to me the biggest advantage is that you can stay focused on building your app and you don't have to worry about setting up all of that server-side architecture it's also very scalable insecure a lot of these platforms are built for the purpose of just being the backend for your app and so if your app takes off and becomes really popular you don't have to worry about buying more servers and replicating your database across the servers and all that stuff because these platforms are built for that and it just kind of happens automatically behind the scenes it ends up saving you a lot of time because it's not just the setup right it's the maintenance as well so if you have your own databases in your own servers to worry about your worrying about your servers and keeping them patched and up-to-date if you you know get attacked by hackers or something like that then you're worried about getting your servers back up and running not to say that these platforms can be hacked or can be under attack but it's just that you won't have to worry about getting them back up and running and lastly these platforms make it really easy to use like I mentioned they have frameworks you can just add to your Xcode project and start using so in the following lessons we're going to be looking at one of these backends as a service called parse and it's got a very generous free plan so you don't have to worry about paying unless your app becomes really popular and it's actually my favorite one out of them all if you're interested in MySQL or using iCloud as a back-end then check out the iOS toolbox course on my site where I cover those two platforms and many other topics but in the upcoming lessons I'll show you guys how to integrate parse into your project and how to save and retrieve data all right bye for now and I'll see you guys in the next lesson
Info
Channel: CodeWithChris
Views: 66,565
Rating: undefined out of 5
Keywords: XCode Tutorial, XCode, iOS Tutorial, iPad, iPhone, Develop, Create, Build, Code, How To, iOS, iPhone Apps, iPad Apps, Objective C, Developer, Introduction, Build iPhone Apps, Walkthrough, Step by Step, Apple, Programming, Learn, Beginner, Development, CodeWithChris, Code With Chris, Swift, App Store, Xcode 6, iOS 8, iOS8, How to Make an App, How to Make an iPhone App, How to Create an App, How to Create an iPhone App, Make, database, parse, cloudkit, icloud
Id: IVItNKOITxg
Channel Id: undefined
Length: 8min 35sec (515 seconds)
Published: Thu Feb 12 2015
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.