Introduction to Relational Databases in SQL
Learn how to create one of the most efficient ways of storing data - relational databases!
Start Course for Free4 hours13 videos45 exercises150,840 learnersStatement of Accomplishment
Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.Training 2 or more people?
Try DataCamp for BusinessLoved by learners at thousands of companies
Course Description
Explore the Role of SQL in Relational Database Management
There are a lot of reasons why SQL is the go-to query language for relational database management. The main one is that SQL is a powerful language that can handle large amounts of data in complex ways and solve tricky analytical questions. In this course, you will gain an introduction to relational databases in SQL.Learn how to create tables and specify their relationships, as well as how to enforce data integrity. Additionally, discover other unique features of database systems, such as constraints.
Create Your First Database
You begin the course by creating your first database with simple SQL commands. Next, you’ll learn how to update your database as the structure changes by migrating data and deleting tables.In the final chapter, you will glue tables in foreign keys together and establish relationships that greatly benefit your data quality. Finally, you will run ad hoc analyses on your new database.
Understand the Basics of Relational Databases
By the end of the course, you will gain a basic yet essential understanding of SQL relational databases. They are widely used in various data science fields (from healthcare to finance) and have consequently become one of the crucial languages for data scientists. If you're interested in deepening your knowledge further, you may be interested in our SQL for Database Administrators, SQL Server Developer, and SQL Server for Database Administrators Tracks.Training 2 or more people?
Get your team access to the full DataCamp platform, including all the features.In the following Tracks
Associate Data Engineer in SQL
Go To TrackSQL for Database Administrators
Go To TrackSQL Server Developer
Go To Track- 1
Your first database
FreeIn this chapter, you'll create your very first database with a set of simple SQL commands. Next, you'll migrate data from existing flat tables into that database. You'll also learn how meta-information about a database can be queried.
Introduction to relational databases50 xpAttributes of relational databases50 xpQuery information_schema with SELECT100 xpTables: At the core of every database50 xpCREATE your first few TABLEs100 xpADD a COLUMN with ALTER TABLE100 xpUpdate your database as the structure changes50 xpRENAME and DROP COLUMNs in affiliations100 xpMigrate data with INSERT INTO SELECT DISTINCT100 xpDelete tables with DROP TABLE100 xp - 2
Enforce data consistency with attribute constraints
After building a simple database, it's now time to make use of the features. You'll specify data types in columns, enforce column uniqueness, and disallow NULL values in this chapter.
Better data quality with constraints50 xpTypes of database constraints50 xpConforming with data types100 xpType CASTs100 xpWorking with data types50 xpChange types with ALTER COLUMN100 xpConvert types USING a function100 xpThe not-null and unique constraints50 xpDisallow NULL values with SET NOT NULL100 xpWhat happens if you try to enter NULLs?50 xpMake your columns UNIQUE with ADD CONSTRAINT100 xp - 3
Uniquely identify records with key constraints
Now let’s get into the best practices of database engineering. It's time to add primary and foreign keys to the tables. These are two of the most important concepts in databases, and are the building blocks you’ll use to establish relationships between tables.
Keys and superkeys50 xpGet to know SELECT COUNT DISTINCT100 xpIdentify keys with SELECT COUNT DISTINCT100 xpPrimary keys50 xpIdentify the primary key50 xpADD key CONSTRAINTs to the tables100 xpSurrogate keys50 xpAdd a SERIAL surrogate key100 xpCONCATenate columns to a surrogate key100 xpTest your knowledge before advancing100 xp - 4
Glue together tables with foreign keys
In the final chapter, you'll leverage foreign keys to connect tables and establish relationships that will greatly benefit your data quality. And you'll run ad hoc analyses on your new database.
Model 1:N relationships with foreign keys50 xpREFERENCE a table with a FOREIGN KEY100 xpExplore foreign key constraints100 xpJOIN tables linked by a foreign key100 xpModel more complex relationships50 xpAdd foreign keys to the "affiliations" table100 xpPopulate the "professor_id" column100 xpDrop "firstname" and "lastname"100 xpReferential integrity50 xpReferential integrity violations50 xpChange the referential integrity behavior of a key100 xpRoundup50 xpCount affiliations per university100 xpJoin all the tables together100 xp
Training 2 or more people?
Get your team access to the full DataCamp platform, including all the features.In the following Tracks
Associate Data Engineer in SQL
Go To TrackSQL for Database Administrators
Go To TrackSQL Server Developer
Go To TrackTimo Grossenbacher
See MoreHead of Newsroom Automation at Tamedia
Timo Grossenbacher is Head of Newsroom Automation at Swiss publisher Tamedia. Prior to that, he used to be a data journalist working with the Swiss Public Broadcast (SRF), where he used scripting and databases for almost every data-driven story he published. He also teaches data journalism at the University of Zurich and is the creator of rddj.info – resources for doing data journalism with R. Follow him at grssnbchr on Twitter or visit his personal website.
FAQs
Join over 15 million learners and start Introduction to Relational Databases in SQL today!
Create Your Free Account
or
By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.