Information Object Counter

18 views
Skip to first unread message

Anand chavan

unread,
Aug 25, 2023, 2:29:52 AM8/25/23
to AtoM Users
Dear All,

I am trying to develop a files counter program which will reflect number of files or information objects inside perticular Fond, Series or Subseries. Does anyone have idea that how can we use AtoM database structure for it?

Thanks and regads,
Anand.

Dan Gillean

unread,
Aug 25, 2023, 2:26:16 PM8/25/23
to ica-ato...@googlegroups.com
Hi Anand, 

I spoke with one of our developers, who pointed me to a similar function we use in AtoM's code, that we can borrow for what you need: 

We have some basic SQL queries in our documentation here, which includes how to back up your database, and how to access the MySQL command prompt. I STRONGLY recommend you make a backup before attempting to use SQL in a production database - ideally, you would make a backup, load it into a test site, and perform your queries there first! Anyway, see: 
We also have Entity Relationship Diagrams of AtoM's data schema on our wiki. Here is the latest: 
I've recently given a very brief overview of AtoM's data model in this thread: 

For context: AtoM uses a Nested set model to manage hierarchical relationships in the relatively flat, table-like structure of a SQL database. This means that in the information_object table, you will find two fields - lft and rgt. You can use the object ID to find the description you want (we have example queries on how to get this from either a slug or [if it's unique enough] a title in the docs here), and then get these values for the target description. 

Now, that first link? It essentially provides us with an equation you can use to get a count of descendant records (i.e. not just immediate children, but all records in the current hierarchy from the starting record down). That equation is: 
  • (rgt - lft - 1) / 2
That is to say, the rgt value minus the lft value minus 1, and that total divided by 2, should give you a count of descendant records. 

I hope this helps! 

Dan Gillean, MAS, MLIS
AtoM Program Manager
Artefactual Systems, Inc.
604-527-2056
@accesstomemory
he / him


--
You received this message because you are subscribed to the Google Groups "AtoM Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ica-atom-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ica-atom-users/666871a1-05af-4390-9c47-f418aafed856n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages