UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED: Storing Data from a MySQL database

Forums > iOS

Hi All,

So I'm working on a project that will query a MySQL database and store the returns of the queries. The queries will all be identical in nature, but the rough spot we're in is storing returns. I have debated on using Core Data for this, but am looking to see if there are other methods that might be more productive for our purposes.

The first query searches for information related to a specific business. All that is being returned are some basic pieces of information that don't change in quantity: Name, address, phone number, etc. The second and subsequent queries return an optional and undefined amount of of possible records (user comments about the business).

It's possible for up to ninety businesses to be stored in Core Data, but my question is how would you reasonably (in your experiecne) go around storing an optional with no upper limit on how many records could be stored? I think I have a method in my head, and that is to simply rely on a second (unorganized) Data Model to store comments and retrieve from, but this seems slow and messy in application.

Thanks, Andy

2      

I think this one probably for @Obelix to answer

If I right you have Company -> many Comment

So

class Company {
  var name: String
  var address: String
  var phone: String
  var etc: ......
  var comments: [Comment]
}

class Comment {
  var date: Date
  var text: String
}

I have included date as a way to sort them eg newest first

Then look at Ultimate Portfolio App (as you are subscribe to HWS+) on how to use it in CoreData (Issue = Company & Tag = Comment), however you might want to do in the New SwiftData which I am sure that Paul will do soon.

3      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.