From the course: Programming Foundations: Databases

Understanding databases: Benefits of spreadsheets

From the course: Programming Foundations: Databases

Start my 1-month free trial

Understanding databases: Benefits of spreadsheets

- A database gives us a way to add structure to data and to define rules that the data must follow. The whole point of having data is to be able to use it for something, and a database gives us the tools both to protect data and to use data to answer questions. Imagine you have a restaurant, and you've got a few customers who are really good loyal regulars. They support your business, and they're great about referring new customers, so you decide you want to give them some perks. You'll invite them to a holiday party this year and once they've ordered 10 meals in your restaurant, you'll offer them half off their favorite dish. First, you'll need a record of who they are. You could write down each customer's information on an note card. You might record their name, and email or phone number they've used for reservations in the past, and maybe their birthday, if they've given you that information too. For a few customers, the set of note cards is fine, but as you get more of them, it's harder to tell which of the pieces of information you have for each customer. And it's hard to look them up to keep track of the meals they've ordered, because, unless you've spent the time to move the cards around in the stack, they're not sorted by name or by birthday or by anything, really, and to send out invitations to the holiday party, you have to copy the information over to invitations manually. That's no fun. At this point, the data is unstructured and it can be helpful to move it into a spreadsheet, where you can add some structure, and more easily work with each customer's information. With this little bit of structure added, it's a lot easier to see gaps in the data and it becomes easier to do other things like print those party invitations or send happy birthday emails with the name included. Here we have some of the basic structure we'll work with when using databases. We've organized information about a particular thing, in this case, individual customers, into rows, and we've organized pieces of data with the same characteristics into columns, names, email addresses, phone numbers, and so on. Rows are sometimes called records and columns are sometimes called fields. We can clearly see how the information is organized if we look back at the note cards we started with. One card is one record or one row, and each piece of information on the card has a place with a similar data in a field or column, but now we can throw the cards away, because we have our data in a more structured format.

Contents