This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes JDBC and the fly likes why do we use database? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "why do we use database?" Watch "why do we use database?" New topic
Author

why do we use database?

jim li
Ranch Hand

Joined: May 20, 2008
Posts: 180
Hi guys,

i have couple of questions about database:

1. in relational database such as ms access, mysql, oracle, why do we need to split database into different tables instead of putting everything in a single table, such as if we have student, teacher, employee., ect..

2. why do need to build a java web application to access database, instead of using database only.

please provide me some reference and links

thank you
Malatesh Karabisti
Ranch Hand

Joined: Jul 28, 2010
Posts: 153

Looks like you are very new to the internet technology, Just think of the simple scenario Bank Applicaiton

As per your first quesiton let us put all Bank data in to one table called "Master" the data will be like customerName, Acc, LoanAcc, Saving Acc , CurrentAcc, and then branch, branchManager, headBrach, HeadBankManger, numberOfBranch, numberOfEmployees .... Do you think 1000 column are enough are we need more. this makes almost impossible to handle data thats why all data is divided into different table.

Second question why we java web applicaiton..
Just think you don't have web application for bank only thing you have is database. one fine moring you went to bank to deposite some amount. what the officer will do only with database he has to wright insert, update query. Every one in the earth won't know how to write query instead with web application he can enter the amount deposited and submit the form.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42024
    
  64
You're right that there is no "need" to build a web app to access a DB; a desktop app would work just as well (assuming it can be installed wherever it's needed). Prior to 1994 or so, no web apps existed at all, and the world was able to access its DBs just fine :-)


Ping & DNS - my free Android networking tools app
Malatesh Karabisti
Ranch Hand

Joined: Jul 28, 2010
Posts: 153

ya thats true NOT necessarily the Web applicatiion we need application to acces the database to make UI friendly.
Tuna Töre
Ranch Hand

Joined: Aug 17, 2008
Posts: 219

Ulf Dittmer wrote:You're right that there is no "need" to build a web app to access a DB; a desktop app would work just as well (assuming it can be installed wherever it's needed). Prior to 1994 or so, no web apps existed at all, and the world was able to access its DBs just fine :-)


what a good period of time

Tuna TÖRE


blog: http://tunatore.wordpress.com
SCJP 6.0 + SCWCD 1.5
Rahul Sudip Bose
Ranch Hand

Joined: Jan 21, 2011
Posts: 637

why did people start accessing database using a web-app ?


SCJP 6. Learning more now.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42024
    
  64
Rahul Sudip Bose wrote:why did people start accessing database using a web-app ?

People create web apps because they have certain advantages over desktop apps. And the web apps need access to the same data, obviously.
Rahul Sudip Bose
Ranch Hand

Joined: Jan 21, 2011
Posts: 637

Ulf Dittmer wrote:
People create web apps because they have certain advantages over desktop apps. And the web apps need access to the same data, obviously.


What are the advantages and when does one prefer one option over the other ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42024
    
  64
Let's keep this thread confined to the original topic.
chris webster
Bartender

Joined: Mar 01, 2009
Posts: 1726
    
  14

1. in relational database such as ms access, mysql, oracle, why do we need to split database into different tables instead of putting everything in a single table, such as if we have student, teacher, employee., ect..


Because the tables represent the different entities, and the entities are essentially the "relations" that the "relational" model is built on, and you can then define relationships between them. You store the apples with the other apples, and the oranges with the other oranges, and so on. Of course, if you have several entities that have the same attributes and level of granularity e.g. you decide to just treat apples and oranges as "Fruit", then you can choose to store them as different sub-types in the same table.

But generally, if you put all your data in one big unstructured table, you don't have a relational database, you just have a mess (unless you're using a non-relational technology such as Amazon's or Google's "big tables", which have their own rules and restrictions). You wouldn't even design a spreadsheet that way - you'd put different kinds of data in different tables/sheets, wouldn't you?

This is not the place to launch into "Relational Databases 101", but relational DBs are based on a robust theoretical foundation about how to structure data for storage/access, and RDBMS implementations are massively optimised to support this approach, as well a providing lots of tools to help you do this. We've been using relational databases for about 30 years, and despite the appearance of alternatives (e.g. OO databases, Hadoop, BigTable etc), they're still performing pretty well for most mainstream applications. If you're planning to work in commercial IT, you'll be working with a relational database at some point, so it might be an idea to start learning about how and why they're used.

Data is not just a passive lump of bytes, it has its own rules and structures and behaviour, that you encode in your application and in table constraints, key relationships etc. So you write database applications to embody this behaviour and integrate it with your specific business processes for creating/manipulating the data as appropriate for your needs.

As for using a web application to access the database, that's essentially just a choice of user interface and a corresponding platform for that interface. But it's the underlying data and its internal logic/structure that are important, because these are the resources your organisation will still be using 10 years from now when today's cool new HTML5/JEE interface has long since been replaced with some other technology. That's why they call it a persistence layer, because data persists and - if you get it right - remains useful a lot longer than anybody expects.

Hope this helps!

Chris

No more Blub for me, thank you, Vicar.
jim li
Ranch Hand

Joined: May 20, 2008
Posts: 180
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: why do we use database?