Page 1 of 1

Data options

Posted: Fri Jun 15, 2012 6:47 pm
by Newbie4
I am a teacher and want to write an application to manage my classes. I am having trouble getting started because there are so many options in LiveCode for working with and saving data. I have written some small programs and experimented with the different ways but I do not want to start a big project only to find out later that there was a better way to do it.

I have been studying all the examples, Academies, documentation and am still confused. The ToDo List example saves the data in custom properties. Some examples use Data Grids and save the data in CSV files. The documentation also shows saving data in a stack with each card a separate record. But reading about Arrays, they seem the best way to go but I do not know how to read/write the data each time. This is the source of my confusion - there are so many ways and I do not know the best way to do it even though any of them would probably work

I have 6 classes and each class has 35 students. Each student will have many grades, attendance records, etc. So my data will be a 3-level tables, at least. The documentation says that nested arrays are a good way to go. I am not sure how to save them to files for later use.

DataGrids look perfect for displaying and working with my data but I am not sure how to use them with arrays. The examples show how to load/unload datagrids with CSV files but not arrays. Is this possible?

I apologize for such a long posting but I am just looking for someone to point me in the right direction. LiveCode is so powerful and flexible, it is almost overwhelming at first. I have been reading all the documentation and working through all the examples and academies, so I am feeling somewhat comfortable with LiveCode. Actually, I have been having fun writing little applications and really enjoy LiveCode. But now I am starting off on a big project to write an application to help me when school resumes in August and I want to start off right.

Thank you all for your patience and help,

Re: Data options

Posted: Fri Jun 15, 2012 6:52 pm
by BvG
As a Beginner, I would suggest that you stay away from both arrays and the Datagrid. They offer increased complexity, with minimal gain.


If you want to show tabular data, I suggest to use a normal list field, then set the tabstops after you've entered example data containing tabs. To save tabular data on the disk, I suggest you use tab-delimited lists with 'put url ("file:" & thePath)'. These two very simple approaches will get you very far with most data needs.

Re: Data options

Posted: Fri Jun 15, 2012 8:01 pm
by Newbie4
So I should just create 1 big flat file with all the fields in them.

e.g.
class name grade1
1 Jim 85
1 Jim 90
1 Jim 95
1 Sally 80
etc


Won't this be awkward looking up or arranging the data for each class or student?

Would it be hard producing reports like 'All grades for Jim in class 1' or 'All failing grades for class 2' or 'all grades 90 or higher for all classes' ?

Thank you

The datagrid looks like an easier way to work with the data, Can I load the lists easily into a datagrid?

Re: Data options

Posted: Fri Jun 15, 2012 8:15 pm
by Newbie4
BvG wrote:As a Beginner, I would suggest that you stay away from both arrays and the Datagrid. They offer increased complexity, with minimal gain.


If you want to show tabular data, I suggest to use a normal list field, then set the tabstops after you've entered example data containing tabs. To save tabular data on the disk, I suggest you use tab-delimited lists with 'put url ("file:" & thePath)'. These two very simple approaches will get you very far with most data needs.
You are saying that I should save my data to a file instead of putting it into a stack (with each student on a card)?

Re: Data options

Posted: Sat Jun 16, 2012 12:49 am
by townsend
BvG was saying as a beginner, working with Field Lists would be the easiest way to go, especially considering all of LiveCodes really easy text, column and line manipulation syntax. He's right. I always use the Field Lists whenever possible.
But you wrote:I have 6 classes and each class has 35 students. Each student will have many grades, attendance records, etc.
So my data will be a 3-level tables, at least.
While it is possible to link Field Lists, it does take some doing, and planning. If you approached a consultant to do this for you, they would ask, "Exactly what kind of reports do you want to produce?" You should take the time to do simple mock ups of all the reports you want. This way you won't get stuck in a corner.

If you do decide to go with a relational tables, you will absolutely need a SQL database manager.
There are many out there including some very good free ones.

Here's a free FireFox extension I've never tried. But it's got 162k downloads.

I use SQLite Expert. They have a free version which is excellent.

As for learning how to use LiveCode's DataGrid with it's built in SQLite engine,
here's a good example project I wrote a while back. SQLite CRUD Example. (That's: Create, Read, Update & Delete.)
It's got 248 downloads. Let me know if you have any questions.

Re: Data options

Posted: Sat Jun 16, 2012 5:00 am
by dunbarx
Couldn't you just create a stack with all your students, one per card? Each card could contain all the relevant date you wish, including which class they were in. Though is seems as if this does not organize itself based on your classes as a foundation for your information, gathering the data necessary to create any sort of report would be straightforward, the class to which a student belongs, for example, being only one of many criteria, all of which may be gleaned in clever ways from a coherent card based gadget.

More importantly, the learning you will gain by pursuing any of these simpler (I agree, no DG, SQL or other fancy stuff) methods will be more important than choosing a "best" methodology. You WILL create a working useful stack. You WILL become far more proficient very quickly overall. You will not waste your time.

Craig Newman

Re: Data options

Posted: Sat Jun 16, 2012 8:59 pm
by townsend
But you wrote:I have 6 classes and each class has 35 students. Each student will have many grades, attendance records, etc.
So my data will be a 3-level tables, at least.
I have another idea. This is something I'm thinking of doing for one of my projects, but I talk in terms of your project. For simplicity sake, let's say each student has just grades and attendance records. Without going into the complexity of a relational database, you can duplicate almost all the functionality relational database with a BIG array. Especially considering how LiveCode allows you to reference array records by a named index.

For instance. One array to hold 6 classes. Then within each of those 6 more arrays, each holding a list of students. Then within each student array, you have two more arrays. One to hold grades, and the other to hold attendance.

Once you get through the initial difficulty of how to put one array into another array, and populate drop down menus with class and student names, it should all fall into place quickly.

For instance, you would have four data entry forms. 1- For entering classes. 2- Select Class, entering Student Name. 3- For attendance it would be simpler to keep track for missed classes, rather than actual attendance for each student. 4- Then for grades you have to give each report or exam a name. You'd then populate a Text Field with all the students names and as you scroll down the list, one student at a time, simply entering the grade. That's data entry.

You can then create various repeat loops to display and print any number of informative reports-- detail or just averages. These reports would be just dumped into a tab delimited text field. With the Code Editor and your Text Field open at the same time, this would be very easy to debug and design. Easy to print too.

Finally you can just save the entire stack with one command, which includes all the data in your arrays. Of course when you open the stack again, another one line command restores all your data.

Re: Data options

Posted: Sat Jun 16, 2012 11:32 pm
by dunbarx
Valid and compact.

But this is not a novice task. Much of the effort will be spent in building, analyzing and extracting data from an array project, as opposed to a student information project.

The learning will be narrowly concentrated on becoming array proficient as opposed to LC proficient. Unless I am mistaken, this is putting the carrot before the hearse.

Craig Newman

Re: Data options

Posted: Mon Jun 18, 2012 10:59 pm
by Newbie4
dunbarx wrote:Couldn't you just create a stack with all your students, one per card? Each card could contain all the relevant date you wish, including which class they were in. Though is seems as if this does not organize itself based on your classes as a foundation for your information, gathering the data necessary to create any sort of report would be straightforward, the class to which a student belongs, for example, being only one of many criteria, all of which may be gleaned in clever ways from a coherent card based gadget.

More importantly, the learning you will gain by pursuing any of these simpler (I agree, no DG, SQL or other fancy stuff) methods will be more important than choosing a "best" methodology. You WILL create a working useful stack. You WILL become far more proficient very quickly overall. You will not waste your time.

Craig Newman
What you say makes sense and I started to do that. However, I ran into problems inputting the other data. How do I enter attendance - as a text field or list of each student missed classes on their card? What about the assignments and the grades - should that be a text field, list, or array on each card. I need the date of the assignment, the assignment and the grade for each student. I am not sure how to structure that.

The reports is another issue and a bit perplexing for me at this stage. Fo a class list, do I step through each card and assemble the information into a text field and print that? For individual student reports, do I just build a text field and print that? What about an assignments report, I would have to step through every card again and build a list and print that.

I guess I am finding a card structure too simple. It seems like the other data structures (arrays, lists, data grids) lend themselves to the actual data better.

Every year, I get my student enrollment in CSV files. I found it was easy to import them into a data grid but did not know what to do about the rest of my data - attendance, assignments, grades, etc.

So I see your point about start with basics and just getting more familiar with the language. I got the one student per card sort of working but still have many issues to be worked out in my mind.

Thanks for your recommendations

Re: Data options

Posted: Mon Jun 18, 2012 11:14 pm
by Newbie4
townsend wrote:
But you wrote:I have 6 classes and each class has 35 students. Each student will have many grades, attendance records, etc.
So my data will be a 3-level tables, at least.
I have another idea. This is something I'm thinking of doing for one of my projects, but I talk in terms of your project. For simplicity sake, let's say each student has just grades and attendance records. Without going into the complexity of a relational database, you can duplicate almost all the functionality relational database with a BIG array. Especially considering how LiveCode allows you to reference array records by a named index.

For instance. One array to hold 6 classes. Then within each of those 6 more arrays, each holding a list of students. Then within each student array, you have two more arrays. One to hold grades, and the other to hold attendance.

Once you get through the initial difficulty of how to put one array into another array, and populate drop down menus with class and student names, it should all fall into place quickly.

For instance, you would have four data entry forms. 1- For entering classes. 2- Select Class, entering Student Name. 3- For attendance it would be simpler to keep track for missed classes, rather than actual attendance for each student. 4- Then for grades you have to give each report or exam a name. You'd then populate a Text Field with all the students names and as you scroll down the list, one student at a time, simply entering the grade. That's data entry.

You can then create various repeat loops to display and print any number of informative reports-- detail or just averages. These reports would be just dumped into a tab delimited text field. With the Code Editor and your Text Field open at the same time, this would be very easy to debug and design. Easy to print too.

Finally you can just save the entire stack with one command, which includes all the data in your arrays. Of course when you open the stack again, another one line command restores all your data.
I like the way you think. Your approach makes sense but I ran into problems trying to implement what you are describing. I did not have as many answers as you do

For instance, how do you do arrays inside of arrays? The documentation says it is a good way to go but does not really say how. It seems overly complicated with out code samples to study.

Also, were you planning on using data grids? They look like they work well in these situations. I was able to load my student lists from CSV files into a data grid and it really looks slick but I was not sure how to allow editing fields in data grids. I found some code samples and tried them but they did not work for me. I started wondering if I was starting down too steep of a slope.

Is there a better way to work with/edit arrays? (Like unpacking them into simple lists, editing those in a form and then putting the new text back into the array?

If not data grids, would you recommend tables? From what I found in the Doc, they are somewhat limited but they may serve to enter grades for the students. Or is a list as you suggested the simplest and best?

Thanks for your suggestions. I welcome any other ideas and hints that you may have.

Re: Data options

Posted: Mon Jun 18, 2012 11:48 pm
by townsend
Newbie4 wrote: For instance, how do you do arrays inside of arrays? The documentation says it is a good way to go but does not really say how. It seems overly complicated with out code samples to study.
Yes-- you need code samples. Start with just simple arrays. There's lots of codes samples there. Also, one of the great things about arrays. Is you can always view the contents and structure in the debugger, under Variables.
Also, were you planning on using data grids? They look like they work well in these situations. I was able to load my student lists from CSV files into a data grid and it really looks slick but I was not sure how to allow editing fields in data grids. I found some code samples and tried them but they did not work for me. I started wondering if I was starting down too steep of a slope.
No need to use DataGrids. Scrolling text fields is all you need. You can dump CSV data into a text field too, but you'll need to code a special button to import and correctly distribute them into your arrays.

If you decide to go forward with this project, I'd suggest you break it up into small pieces. Then, as need be you can post questions relating to the specific challenges you face. It's slow going for everyone in the beginning-- but once you get comfortable with the Dictionary and looking things up in the User Guide, you'll be surprised at how fast you can figure things out on your own. I was.

You should definetly pick up on the 60 Small Business Academy Videos. It looks like they're free to new and old users alike.
That will definitely save you a LOT of time.