True enough, and if you are only reading, atomicity doesn't matter.

But if you want to record answers?

Files are well suited to either read-only uses. But once you start
writing, you have the potential for partial updates unless you use a
rename or delete to mark the end of the update. Which is done far too
seldom.

SQL and databases are a skill I recommend for any well-rounded
programmer.

On Aug 3, 12:18 pm, DanH <danhi...@ieee.org> wrote:
> "Further, while with some careful attention to detail, you can get
> reliable operation with files, even if the device is turned off at a
> bad moment -- too often people don't manage to get it right. (Key idea
> - the only atomic filesystem operations are rename and delete). "
>
> Seems to me that opening a file read-only is fairly atomic.  Don't
> attempt to modify the questions (or store result data in the same
> file) and there's no atomicity problem.
>
> On Aug 3, 1:48 pm, Bob Kerns <r...@acm.org> wrote:
>
>
>
> > I agree.
>
> > My experience with this sort of thing is that frequently, if you don't
> > start out with a SQL database, you ultimately end up having to convert
> > it later. So often it's better to start there.
>
> > Here's why. Using a database scales better. If you end up with a large
> > quiz, you'll have to load it all into memory at once -- or split it up
> > into lots of files. XML or JSON become the "wasty" approach, as Paul
> > put it, beyond a certain point.
>
> > Further, while with some careful attention to detail, you can get
> > reliable operation with files, even if the device is turned off at a
> > bad moment -- too often people don't manage to get it right. (Key idea
> > - the only atomic filesystem operations are rename and delete).
>
> > With a database, you still have to think about transactions, but you
> > can group any set of operations in a transaction, and there is a
> > single, reliable mechanism for reliable transactions. You don't have
> > to invent your own.
>
> > I would definitely use multiple tables. For example
>
> > Question:
> > * id (primary key)
> > * answerID (foreign key constraint on answer table, do not chain on
> > delete)
> > * number (if you want to define a numbering for your questions).
> > * text
>
> > Answer:
> > * id (primary key)
> > * questionId (foreign key constraint on question table, chain on
> > delete -- i.e cause this to be deleted if the question is deleted).
> > * number (if you want to control for a consistent order, rather than
> > randomize it).
> > * text
>
> > If you're recording the responses:
>
> > Response:
> > * id (primary key)
> > * questionID (foreign key constraint on question table, chain on
> > delete)
> > * answerID (foreign key constraint on answer table, chain on delete).
>
> > You'll also want to define indexes -- for example, on
> > Response.questionID, which should probably also be unique (and
> > Answer.questionId, which should not, or Answer.questionId, number,
> > which should).
>
> > Then you can quickly find question #2345098 and its answers, and
> > consume no more storage and little more time than if you had just 10.
>
> > On Aug 3, 6:09 am, "saify.zeenwala" <saifyzeenw...@gmail.com> wrote:
>
> > > Hi
>
> > > Better opt for SQL as it would be convenient for you to do further SQL
> > > query.
> > > where as in property file you have to do manual search and have to do 
> > > string
> > > operation.
>
> > > create table with 3 columns
>
> > > question
> > >  possibleanswer
> > > correct answer
>
> > > Might be this will help you
>
> > > On Tue, Aug 3, 2010 at 2:19 AM, amos <milan.ku...@gmail.com> wrote:
> > > > Hello,
> > > > I want to create such application that would show a question to user
> > > > and possible 3 (or n) answers and user should pick correct answer
> > > > (some kind of learning quiz). I'm not sure about the storage for those
> > > > data - questions and possible answers. What would be most natural way
> > > > for Android. I know that I can either use property files or tables in
> > > > sqlite database. There will be about 500 items (1 question, 3 answers,
> > > > 1 correct answer ).
> > > > Any ideas?
> > > > Thanks
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > > > Groups "Android Developers" group.
> > > > To post to this group, send email to android-developers@googlegroups.com
> > > > To unsubscribe from this group, send email to
> > > > android-developers+unsubscr...@googlegroups.com<android-developers%2Bunsubs
> > > >  cr...@googlegroups.com>
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to