Organizing Data with Databases2:58 with Andrew Chalkley
Databases allow users to store data in well defined sections. This keeps the data uniform. However, the SQL you write can show the data in different ways which is handy for reporting subsets of data.
There are two important components to each data base. 0:00 The information that's stored in it called data, and 0:03 how the data is organized called the schema. 0:06 The schema establishes how that data should be stored and 0:09 divided into different sections. 0:12 The schema further determines how each of the sections relates to other sections. 0:14 These sections are called tables. 0:19 It's easy to picture a database by thinking of the spreadsheet. 0:22 You know what spreadsheets look like from programs such as Microsoft Excel, 0:26 Apple Numbers, and Google Sheets. 0:30 They look like a large grid composed of columns and rows. 0:32 Rows from left to right horizontally, and the columns run top to bottom, vertically. 0:36 Just remember columns are like the columns supporting a building, they're vertical. 0:42 And the rows are like the rows of a corn field, horizontal. 0:46 Remember, the sections of a database are called tables. 0:51 You can think of a table as its own spreadsheet full of rows and columns. 0:54 Typically, each table contains data for a specific type of thing. 0:59 For example, If I ran a T-shirt store, I would want to store my inventory in 1:03 one spreadsheet or table, and the orders in another spreadsheet or table. 1:08 Let's have a look at what the inventory table would look like. 1:12 Each row represents a single thing. 1:16 In the case of inventory it's a particular shirt type. 1:19 With it's name, size, price, and stock count. 1:23 Now let's look at the orders table. 1:27 [NOISE] We have the columns product name, size, price, 1:29 quantity ordered, customer name, and customer address. 1:33 Each row in this case is an individual order. 1:38 Like in our example the database tables contain data 1:42 with each table containing one type of thing. 1:46 Orders and inventory. 1:48 Let's look at the inventory spreadsheet as if it were a database table now. 1:50 Depending on the SQL you write, you can filter information. 1:54 [SOUND] For example, you could filter the table to get all of the items 1:58 in the inventory table that have the stock count greater than 15. 2:03 You don't even have to show all columns. 2:08 In fact, you can arrange the columns in any order you want. 2:11 Now this an important note. 2:16 When you filter data in this way, no data has been deleted from the table. 2:18 You're just selecting what information you want to bring back 2:23 from the table with that query. 2:26 All information is still in the database table. 2:28 You can bring it all back with no trouble. 2:31 Because of both SQL's flexibility and 2:34 the fact that the queries leave your underlying data untouched, 2:36 your data can be used in many different applications and settings repeatedly. 2:40 From the website view a user sees. 2:45 To a more detailed view in an administration panel. 2:47 To a report being run by a business analyst. 2:50 The same data can be shown in different ways. 2:53 And that's the true power of SQL. 2:56
You need to sign up for Treehouse in order to download course files.Sign up