• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can Database storage and queries replace all Collections and arrays(which basically hold datas)  RSS feed

 
Sawan Mishra
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone
My friends and me are trying to make online Test taking system.
We got a very basic doubt or dumb doubt.

We have developed classes and relationship between classes for example
Online Test Taking system will have admin and student class.
And Admin will have list of students.. etc.
But question troubled me was:
if we use database to store all data for example student details
then I can perform all sorts of operations writing sql query and store
result in some other database then
what is the need of "ArrayList<Student> field in Admin".??

Question is:
We can put everything in database and manipulate using database(sql) functions
to manipulate it.Then what is the need of Arraylist of anything which is just
used to store object details for example student details....??


Thanks in advance
with regards
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sawan Mishra wrote:Question is:
We can put everything in database and manipulate using database(sql) functions
to manipulate it.Then what is the need of Arraylist of anything which is just
used to store object details for example student details....??

Simple answer: there isn't a need. You could write a program that simply queries the database for every individual thing it needs.

However, programs (and programming languages in particular) usually have lots of memory at their disposal, and so are designed to deal with collections of things, so it makes sense to have some ways of holding lots of items.

Databases are more concerned with storing things - something called "persistence" - so that you can retrieve them later on when you need to; so it's perfectly possible that you have two things (your program and your database) that need to deal with the same sorts of structures. Your program, so that you can handle lots of objects while you need to do something, and your database to store them for future use.

Hope it helps; if not, tell us why not.

Winston
 
Sawan Mishra
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so it's perfectly possible that you have two things (your program and your database)
that need to deal with the same sorts of structures. Your program, so that you can handle lots
of objects while you need to do something, and your database to store them for future use.



Even I had also thought in this way but my friends are not convinced with this answer.They are saying
database can store data for future use and also at the same time we can manipulate data and keep
the result in some other table.And I can't find anything to counter them.
I know that for storing list of items in a program we need Collections and to store the data in persistent
memory for future use we use database..
But the problem my friend's approach can also do the same!!!
So I'm getting confused.
please help me


thanks in advance
with regards
 
Campbell Ritchie
Marshal
Posts: 56553
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is very common to find that two different approaches give the same result.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sawan Mishra wrote:Even I had also thought in this way but my friends are not convinced with this answer.They are saying
database can store data for future use and also at the same time we can manipulate data and keep
the result in some other table.And I can't find anything to counter them.

Probably because they're absolutely right. Databases are extremely powerful, and you can do an awful lot of stuff with them. However, they're also a bit of a "one-trick pony", so if you want to write entire applications that work only within the bounds of the database, you may be obliged to accept the restrictions they impose - like working with forms, or clunky, hybrid languages like PL-SQL.

Java, on the other hand, was written specifically as a "run-anywhere" programming language, and almost from its inception was designed with the World Wide Web in mind; so it has tons of tools for developing web apps or collections or games of enormous variety.

Could you install an Oracle database on a smartphone? Possibly these days; but would you want to? The fact is that you probably could install a JavaDB on one; and even if you don't want to do that, you could still write a Java program for one that could communicate with an Oracle database.

Hope it helps you with your argument.

Winston

[Edit] Actually, according to this page, you can't run JavaDB with Android; but there are others you can.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!