How To Manage Related Records at Run-Time with SQLite

I’m attempting to use SQLite to store user-generated data. However, I’m unsure of the particular pattern I should be using.

Should I give the run-time objects the ID of the SQLite table records, so when I import them for use, I have those IDs available for when I need to create related records?

Let’s say I have a table, BodyParts. I have a table, Muscles, which describe muscles per BodyParts.

So, let’s say my user wants to input the “Pectoralis major” in Muscles, with the related BodyPart, “chest.”

When I go to create the Pec record, do I just query BodyParts for the ID of “chest?” Or would it be just as legitimate to already have that ID in the object?

I hope that’s clear!

tl;dr Is it a legitimate pattern to load SQLite tables into objects at app start, including their DB IDs? If not, what’s the best way to manage user-generated content?

Even better, there’s a way to load records into objects when you need the data. You should check out Active Record and ARGen. https://bkeeney.com/argen

Active Record is an ORM, which means that you can use Xojo objects to manage database records. ARGen will handle the process of creating all the subclasses for each table in a database.

[quote=483338:@Tim Parnell]Even better, there’s a way to load records into objects when you need the data. You should check out Active Record and ARGen. https://bkeeney.com/argen

Active Record is an ORM, which means that you can use Xojo objects to manage database records. ARGen will handle the process of creating all the subclasses for each table in a database.[/quote]

Thanks for the heads-up! That sounds pretty nice. I’ll check it out.

Unfortunately, this is a hobby project at the moment, and I’m using the latest Xojo. There was a warning about incompatibility with API2.0. Not sure if that applies, but maybe in the future!