Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
      You have completed Hibernate Basics!
      
    
You have completed Hibernate Basics!
Preview
    
      
  As a first stop on your way to Hibernate, you will first need to review a few basic concepts about relational databases.
Database Courses
Database Resources
- Cheatsheet for SQL SELECT statements
 - Cheatsheet for modifying data with SQL
 - Relational database concepts
 
Non-Relational (NoSQL) Database Vendors
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
                      To start on our path towards databases
with Java, let's consider this scenario.
                      0:00
                    
                    
                      You download a new contact
manager app to your phone.
                      0:05
                    
                    
                      And eager to use all
its new sleek features,
                      0:08
                    
                    
                      you start adding your friends and
family's contact info.
                      0:11
                    
                    
                      After adding a handful of people,
                      0:14
                    
                    
                      you're interrupted by an important
Facebook notification.
                      0:16
                    
                    
                      Your mom just posted a throwback Thursday
photo of you when you were nine years old,
                      0:19
                    
                    
                      all decked out for trick or
treating on Halloween.
                      0:23
                    
                    
                      Mom, you like the photo then switch
back to the contact manager app.
                      0:26
                    
                    
                      A wave of anger overcomes you as you
realize all your contacts are gone.
                      0:32
                    
                    
                      With quick testing, you realize
that every time you leave the app
                      0:37
                    
                    
                      all the data you've entered disappears.
                      0:40
                    
                    
                      What this app lacks is an acceptable
answer to the following question.
                      0:44
                    
                    
                      What good is an application
whose underlying data is lost
                      0:48
                    
                    
                      when the application unexpectedly
goes down, is updated, or
                      0:51
                    
                    
                      when a user logs out and log back in?
                      0:55
                    
                    
                      What's clearly missing here is some
sort of data storage mechanism.
                      0:58
                    
                    
                      In software,
this is referred to as data persistence.
                      1:03
                    
                    
                      That is, data should live on or persist,
after its application is powered down.
                      1:06
                    
                    
                      This brings us to the most widely
used form of data persistence.
                      1:13
                    
                    
                      And that is the database.
                      1:16
                    
                    
                      If you haven't already,
you should check out our database courses,
                      1:19
                    
                    
                      starting with SQL basics.
                      1:22
                    
                    
                      I've linked to them in
the teacher's notes.
                      1:23
                    
                    
                      But, so that you have a general idea of
the relational database concepts we'll
                      1:26
                    
                    
                      be working with during this course,
let's briefly touch on them here.
                      1:29
                    
                    
                      Think of the relational database
as a set of related spreadsheets
                      1:34
                    
                    
                      where each of the spreadsheets
is called a table.
                      1:38
                    
                    
                      The tables themselves have columns
which some people also call fields.
                      1:40
                    
                    
                      In any given table,
                      1:46
                    
                    
                      the columns refer to the pieces
of information a table will hold.
                      1:47
                    
                    
                      In the case of the contact manager, there
might be a table of contacts, which could
                      1:51
                    
                    
                      have five columns, an ID, first name,
last name, email address and phone number.
                      1:56
                    
                    
                      Being a table, it also has rows.
                      2:03
                    
                    
                      These rows are the actual entries
of data stored in the table.
                      2:05
                    
                    
                      For the contacts table, each row
contains the data for a single person.
                      2:09
                    
                    
                      And even though we could store
a hundred or even a thousand or
                      2:14
                    
                    
                      more people in our contacts table,
                      2:17
                    
                    
                      each row would still only consist of
exactly five pieces of information.
                      2:19
                    
                    
                      [SOUND] Let's take a quick
look at that ID column.
                      2:24
                    
                    
                      Typically, a database table has one column
that uniquely identifies each row in
                      2:28
                    
                    
                      the database, that is,
no two rows can have the same ID.
                      2:33
                    
                    
                      And even if a person's
contact info is updated,
                      2:36
                    
                    
                      the contact's ID will never change.
                      2:39
                    
                    
                      This kind of column is
called the primary key.
                      2:43
                    
                    
                      And all of our tables will
have a primary key column.
                      2:46
                    
                    
                      Finally, a database almost always
uses a specific language to
                      2:50
                    
                    
                      interact with the underlying data.
                      2:54
                    
                    
                      And that language is called structured
query language, or SQL, for short.
                      2:56
                    
                    
                      Think of this as the programmatic
interface for databases.
                      3:01
                    
                    
                      Like an API.
                      3:03
                    
                    
                      That'll do for a database primer for
our purposes in this course.
                      3:05
                    
                    
                      Check the teachers notes for
more on relational databases.
                      3:09
                    
                    
                      Now, why don't you answer a couple
questions before we start coding.
                      3:12
                    
                    
                      I'll see you right back here.
                      3:16
                    
              
        You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up