0:00 I've got a pop quiz for you.
0:02 What database system has been around
0:04 for almost 50 years?
0:07 I guess you can guessed it by the
0:08 topic of this video.
0:10 It's a relational database.
0:12 Hello, my name is Jamil Spain,
0:14 Developer Advocate with the IBM
0:16 Cloud and Brand Technical
0:18 Specialists in the U.S.
0:20 Financial Services market.
0:22 And today's talk, we're going to
0:23 dive a little bit into relational
0:25 databases.
0:26 I'm going to get into some of the
0:27 characteristics of the database
0:29 model and also some benefits
0:32 that it provides for you when making
0:34 your decision that you want to use
0:36 this for your next project
0:38 to get started.
0:39 Let's talk about the structure
0:41 of a relational database
0:42 system.
0:44 It's going to pretty much map
0:46 out your data points
0:48 and bring out the relationships
0:50 in that. And the way that it
0:51 accomplishes that is through.
0:53 The first thing is making tables,
0:55 which represents particular
0:57 items or nouns or particular
0:59 entities of your particular
1:01 system that you want to actually
1:03 prototype. So let's say I
1:05 have a bunch of books.
1:09 Now this is going to be a table.
1:11 It accomplishes the attributes
1:13 of these books by having columns
1:16 and columns will be things like
1:18 name.
1:21 Date.
1:23 OK, maybe author.
1:26 Of course, got to have a author for
1:27 a book and every.
1:30 Table is going to have an ID, feel
1:32 some way to uniquely identify
1:34 it. Each each row
1:37 of this.
1:39 Database table represents an
1:41 actual record or an item,
1:43 a type of book.
1:44 That's how it really fulfills
1:46 that ability to hold the database
1:48 system there.
1:51 And then as you wait, you
1:53 kind of query out this particular
1:55 system is through what we call a
1:58 you will a structured query
2:01 language.
2:02 And it's a particular system, you
2:04 can say select.
2:07 All the books.
2:12 And give me all this data out
2:14 for me to use.
2:15 Now we have one particular item
2:17 here books, but where it really
2:19 comes, you really see the power of a
2:21 relational database.
2:22 Let's say now I want to
2:25 show the authors.
2:30 And the way that relational
2:31 databases can really provide
2:33 the structure of relating these two
2:35 entities together is by
2:37 describing them through a
2:39 particular entity or relationships.
2:41 You have one that you're here about
2:43 where books can have multiple
2:45 authors, so maybe a one.
2:47 To many.
2:51 You can have a one
2:53 to one.
2:55 And just a couple of relationships
2:57 you can you can kind of mirror
2:59 within the database system, so one
3:01 way that I can have this kind of a
3:03 normalized structure is to say
3:05 definitely the authors
3:07 is going to have.
3:09 Its own particular ID
3:11 and name any, any any
3:13 any particular order of attributes
3:15 that I want to describe there,
3:17 but I can also one of these fields
3:19 can be an actual number
3:22 that actually relates to the ID.
3:26 Of this feel, and this is what's
3:27 known as a foreign key.
3:30 And of course, there will be a name
3:31 there, so when I do my query, the
3:33 next query I do, I
3:35 can reference both these tables
3:37 and say, Hey, give me all the books
3:39 and give me more of the author
3:40 information from this table using
3:43 this foreign key to
3:45 describe that particular structure
3:47 there.
3:48 And you can imagine you'll be
3:49 running a lot of these queries a
3:50 lot, and there are some benefits
3:52 or some things that are provided to
3:54 help with those to speed
3:56 up these queries and make them
3:58 operate as efficiently as possible.
4:00 You have the database will provide
4:02 ways that you can kind of set an
4:03 index. Let's say that I'm often
4:05 querying and always trying to pull
4:07 out by name or by date.
4:09 I can set an index.
4:12 On this particular column,
4:14 which will automatically index all
4:16 the values, so the next time you
4:17 run, this query is going to pull
4:19 from what we like to call this cache
4:21 of all the values.
4:23 Most importantly, every
4:24 time new roles are added,
4:27 records are added to this particular
4:30 table. The index keeps building
4:32 this recent, I like to say,
4:34 cache of all these values, so it's
4:35 always keeping up to date
4:38 to work there.
4:39 So this is all the characteristics
4:41 of what you kind of have to model
4:43 out your particular
4:44 application that you want to build
4:46 and describe how the entities
4:48 are related to each other.
4:50 Now let's switch over here to some
4:51 of the benefits that you're going to
4:53 get out of the box with
4:55 a relational database
4:58 that you want to use.
4:59 The first we'll talk about
5:01 is actual
5:03 consistency.
5:10 Now, this is useful because let's
5:11 say there is some point where I want
5:13 to run multiple of these
5:14 transactions.
5:15 Let's say I'm modeling an inventory
5:17 system for an E commerce
5:18 application, and I have the need
5:20 to write several
5:22 queries in a row that may
5:24 manage a couple of
5:26 different subsystems.
5:28 But if one of those queries fails,
5:30 I want the option to be able
5:32 to roll back.
5:36 The whole set of all
5:38 those queries, just to make sure
5:40 that my data always maintains
5:42 some consistency there.
5:44 The second is the option
5:46 to do stored procedures.
5:50 Sounds like a very complicated
5:52 word there.
5:53 But think of store procedures as
5:56 the ability to write multiple blocks
5:58 or functions of code,
6:00 or if there are a certain amount of
6:01 queries that I continue to always
6:03 run, I can kind of model
6:05 these. So it takes me less
6:07 code to write that particular
6:10 to access that same functionality
6:11 with less SQL code.
6:13 And as you start to get into more
6:15 SQL writing with
6:17 relational databases, you'll see
6:19 queries can get pretty big.
6:21 Another way
6:23 you can do this, as well as another
6:24 topic code views here.
6:26 Definitely want to introduce some of
6:27 these keywords as you do your deeper
6:29 dove. You were able to see a lot
6:31 of these and it'd be familiar
6:33 to you.
6:34 And the last one is a mechanism
6:36 to handle locking
6:38 in the database.
6:41 And concurrency.
6:45 Why is that important?
6:50 Well, at some
6:52 point multiple users are going
6:54 to want to use the database, maybe
6:56 at the same time, maybe two
6:57 applications are going to be adding
6:59 in books.
7:00 And if the first application
7:02 is making a particular
7:04 insert into this table.
7:06 You're going to want to make sure
7:07 that the database is locked until
7:09 that right is done and then
7:11 the second application has its
7:13 ability to go in and make its insert
7:15 as well.
7:16 So these are all built into
7:18 a lot of the relational databases
7:20 that you use.
7:21 A lot of these benefits will be
7:23 provided for you out of the box, not
7:24 necessarily something you'll have to
7:27 write in code, but just know
7:29 that you'll have this at top of mind
7:31 when you are kind of selecting
7:33 to use a relational database for
7:35 your next project.
7:37 I hope this is good for you to
7:38 understand the foundation of
7:40 relational databases.
7:42 Talk to you next time.
7:44 If you have questions, please drop
7:46 us a line below.
7:47 And if you want to see more videos
7:49 like this in the future, please
7:51 like and subscribe.