I have created a website that has a store table of our company stores. The store table data will be populated from data it receives via web service. It will have to add new stores, mark stores closed that have been closed, and mark stores as open that have been reopened.
How do I populate this table with the web service?
1) Have some (cron) script that consumes the web service and syncs the data with the stores table?
2) Build this in to the app itself? So that on app start, it syncs the data? Then maybe somehow modify my model to sync data after every 10 minutes of a find (not really sure how this would work)?
3) Any other ideas?
I would go with having a cron job. That would keep the population of the data separate from your application that uses the data. Also, it would mean you can keep your data up to date, even if your application goes offline. Finally, the data could potentially be used by a different application as well? If this is the case, it wouldn't make much sense to tie the population of the data to one of the applications that uses the data.
Why do you need a database? Depending on what you're doing, it may be more practical to just talk to the Web service directly.
Related
I am looking for the proper way for a swift iOS app that relies on, in my case: AWS but has a local persistent data store so that every possible feature of the app can be used offline.
So far, I went from a pillar or two of Core Data to a full core data stack and it is becoming difficult to foresee how to coexist with AWS DynamoDB. While DynamoDB is of a NoSQL structure, Core Data in the way I have set it up is that of a SQLite persistent data store.
I need to eventually download tables and primarily use AWS for most situations where users are online, but if they want to work offline, I need to be prepared. Perhaps I should try to create a singular User entity, because why would I want to store other users offline? Then once internet is active, I could try to push it to my DynamoDB Users (plural) table.
I have created Entity's in Core Data such as Users, Authors, Profile.
In the scenario a user opens the app and has no internet access, I am planning on inserting a Users entity and my goal is to correctly populate Authors and Profile, because this offline end user is definitely a User, and I want to setup at least a Profile for them as well so that they can later tweak with customizations.
I have maybe too many relationships. I want to do this correct.
In simple situations, I understand a Person Entity might have a father, mother, child and how they can all fit nicely into Person, but since I have entities with enough unique attributes that I thought I need to create their own entities,
How should I go about creating an entity that certainly makes a User/Users record and establishes a Profile?
Short answer is this:
Core Data is your local cache whether you are offline or online. If you are online then the app should refresh the Core Data cache when appropriate.
When offline the app should not update the cache.
The User Interface in either case is identical. The user interface feeds from the Core Data cache ONLY.
I suggest watching my talk on MVC-N that is hosted by realm.io.
I have an application which uses the data from web server. When you first launch the app, it downloads the data and then work with it. But what if the data on web site was changed. How can I know from the application that the data was changed, and if so, what data should I download?
My first idea was each time when you run the application to check the number of entries in the local database on your phone and the number of entries on web server, and if they are not equal, delete all data in local database and then download all data again. But I think that it will take more time than if the application just loads 5-10 needed records instead of all data.
The second idea was when the information on the site changes, website somehow has to inform the application to load some records. But I don’t know if it is possible to do(
Another idea was to compare the id of the last entry in the application database with last id on website. And if they are not equal download the information from the next id.
Are there any suggestions how can I accomplish this?
I am not sure that you have any database or web services but my suggestion is parsing data from the web with JSON or XML.
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSXMLParser_Class/
this class reference is will be clear for you.
Also in my opinion, if you are new in swift and want to choose easy way for this operation search for iOS package managers.
If you want to use a package manager for your project, e.g Pod
https://cocoapods.org/pods/Alamofire
would be a good startig point.
Alamofire is an HTTP networking library written in Swift.
Hope to helped you
So here is the basic structure I'm proposing:
Data warehouse (for want of a better word)
E-commerce online
Back-end MIS
etc
So the idea is that I have an Order for example. An order can be created via e-commerce site, or via back-end MIS. Either case the order should filter out to e-commerce to show order to user, and vise versa.
There will be other apps in the future.
So the thinking is, to have a central warehouse that wraps this data in a service API, and then the other apps push / pull to it.
Sound OK? I guess the question is syncing the data. When I create an order, do I push the order at create time to the warehouse, or put it to some queue, or is there some other method to keep all these in sync, assuming, near realtime to realtime sync is required.
Assume your REST server is just another data store. How would each client get updates from a plain old database when needed?
If you had each client poll the data store at regular intervals, that would be one solution.
I am about to build an internal-only iOS app for storing simple business data. The data store will consist of a single entity only, with one entry per day. To start with there will be around two years worth of data (~750 entries).
I want to set the app up to do one-way syncing only. i.e. Only one person can enter data, but others can read it. iCloud is out as it only works for a single user account.
Is there a lightweight way to sync this datastore out from the single write user to the other read users? Setting up a full sync system seems overkill for this case.
Instead of iCloud, you could use one of the online backends such as Parse.com or Simperium. They would allow you to share data using a db and also provide for user accounts, authentication etc. If you want to run the server locally you can investigate DataKit.
I have a website which useses a mysql database for its whole operation . But for a new requirement i need to query a external oracle database( used by other component) and compile a list of items and display in a page in the website. How is it possible to connect to a external database just for rendering a single page.
And is it possible to cache the queried result for say 1 month before invalidating the cache and get the updated list of items. i dont want query the external oracle db for each request.
Why not a monthly job that just copies the data from the Oracle database into the MySQL database ?
As stated by Myers, a simple solution is to accept a data feed. For example, a cron job could pull data from the Oracle database at defined intervals, say daily or weekly, and then insert the data into your web application's local MySQL database. The whole process could be essentially transparent to your web application. The caching interval, or how long you go between feeds, would be up to you.
I'll also point out that this could be an opportunity for an API that would more readily support sharing of data between applications. This would, of course, be more work than a simple data feed, but has the possibility of being more useful to more people.