What is a database
If you jot notes on any scrap of paper lying around, they are hard to find later. That is why a big shop keeps a separate warehouse where goods are stacked in fixed places. Information is no different. A database is a huge warehouse that holds information in an orderly way. It stores things safely even when many people put them in at once, and it quickly finds what you want among a vast amount of information.
A huge warehouse for information
If you jot notes just anywhere, you cannot remember where you put them, so they are really hard to find later. That is why a big shop keeps a separate warehouse that stacks goods in fixed places.
A database is that kind of warehouse. Instead of leaving information scattered, it packs it away neatly and in order, and it records it on the computer's storage so it does not vanish when the power goes off. If the containers in the earlier lessons are used while a program runs, a database is a warehouse for keeping things over the long term.
Tap the scattered notes and the orderly warehouse to compare. Which one makes finding things easier?
In scattered notes, finding even one takes a long search. In an orderly warehouse, if you know the spot, you take it out at once.
Even for the same information, how you store it makes a big difference to how fast you can find it. So in what shape does a database hold information?
Usually organized as a table
A database usually organizes information as a table. One horizontal line is one record, called a row; for example, one person's information is one row.
One vertical slot is a field, called a column. Names go with names and ages with ages, lined up in the same column. A database that organizes information in tables like this is called a relational database, and it is the most widely used kind today.
Tap a row and a column to explore. A horizontal line is one record; a vertical slot is one field.
Organized as a table, it is easy to take in at a glance. Follow a row and one person's information runs along it; follow a column and the same field lines up side by side.
With everything lined up like this, you can tell at once what is where. So how do we put in new information?
Packing it into the right place
When new information comes in, it is not tossed just anywhere. First you decide which table it belongs in: information about a person goes in the person table.
Then each value goes into the right column, one by one: the name into the name slot, the age into the age slot. Each column is also set in advance to hold numbers or text, which prevents mistakes like putting text into the age slot. Only by placing things in the right spots can you find them later without searching around.
Tap each new piece of data to file it into the right column. Fill them all and one row is complete.
Putting each value into its right slot completed one record neatly. Because the spots are fixed, there is no confusion while filling them in.
As records pile up one by one, the table grows longer and the warehouse fills up. But if that is all it is, couldn't we just write it into a file?
How is it different from a file?
Information stays even in a file, but a file is weak in two ways. First, if several people write at once, the contents can get jumbled or go missing. Second, when there is a huge amount of information, finding what you want takes a long time.
A database handles both of these well. Even when many requests arrive at once, it puts them in order and stores them safely, and however much information there is, it finds things fast.
Tap the file and database panels to compare. They differ in whether things stay safe when many arrive at once and in how fast searching is.
The difference is easy to see. A file struggles as the information grows, while a database handles it with ease.
That is why places with lots of information, like online shops, banks, and schools, almost all use databases: to store things safely all at once and to find them quickly at any time. That is the great strength of a database.
Summary
In short: a database is a huge warehouse that holds information in an orderly way. It usually organizes things as tables, where a row is one record and a column is one field.
New information goes neatly into the right slot. What sets it apart from a file is that it stores things safely even when many arrive at once, and finds things fast even among a vast amount of information.
Tap the key points in order to review. (huge warehouse → organize as a table → file into the right slot → safe and fast search)
Now you know what kind of warehouse a database is. We said it packs information neatly into tables.
But when the information reaches hundreds of millions of records, how does it find the one row you want among so many, and so fast? The next lesson looks at how a database finds things.