SQL Tutorial: Database design
Want to learn more? Take the full course at https://learn.datacamp.com/courses/database-design at your own pace. More than a video, you'll learn hands-on coding & quickly apply skills to your daily work.
---
Now, let's learn more about what database design means.
Database design determines how data is logically stored. This is crucial because it affects how the database will be queried, whether for reading data or updating data.
There are two important concepts to know when it comes to database design: Database models and schemas.
Database models are high-level specifications for database structure.
The relational model, which is the most popular, is the model used to make relational databases. It defines rows as records and columns as attributes. It calls for rules such as each row having unique keys.
There are other models that exist that do not enforce the same rules.
A schema is a database's blueprint. In other words, the implementation of the database model.
It takes the logical structure more granularly by defining the specific tables, fields, relationships, indexes, and views a database will have.
Schemas must be respected when inserting structured data into a relational database.
The first step to database design is data modeling. This is the abstract design phase, where we define a data model for the data to be stored.
There are three levels to a data model:
- A conceptual data model describes what the database contains, such as its entities, relationships, and attributes.
- A logical data model decides how these entities and relationships map to tables.
- A physical data model looks at how data will be physically stored at the lowest level of abstraction.
These three levels of a data model ensure consistency and provide a plan for implementation and use.
Here is a simplified example of where we want to store songs. In this case, the entities are songs, albums, and artists with various pink attributes. Their relationships are denoted by blue rho
What You'll Learn
This video tutorial by DataCamp covers the basics of database design, including database models, schemas, and data modeling, with a focus on the relational model and dimensional modeling for data warehouses.
Full Transcript
let's learn more about what database design means database design determines how data is logically stored this is crucial because it affects how the database will be queried whether for reading data or updating data there are two important concepts to know when it comes to database design database models and schemas database models are high-level specifications for database structure the relational model which is the most popular is the model used to make relational databases it defines rows as records and columns as attributes it calls for rules such as each row having unique keys there are other models that exist that do not enforce the same rules a schema is a databases blueprint in other words the implementation of the database model it takes the logical structure more granularly by defining the specific tables fields relationships indices and views a database will have schemas must be respected when inserting structured data into a relational database the first step to database design is data modelling this is the abstract design phase where we define a data model for the data to be stored there are three levels to a data model a conceptual data model describes what the database contains such as its entities relationships and attributes a logical data model decides how these entities and relationships map to tables a physical data model looks at how data will be physically stored at the lowest level abstraction these three levels of a data model ensure consistency and provide a plan for implementation and use here is a simplified example of where we want to store songs in this case the entities are songs albums and artists with various pink attributes their relationships are denoted by blue rhombuses here we have a conceptual idea of the data we want to store here is a corresponding schema using the relational model the fastest way to create a schema is to translate the entities into tables but just because it's the easiest doesn't mean it's the best let's look at some other ways this er diagram could be converted for example you could opt to have one table because you don't want to have to run so many joins to get song information or you could add tables for genre and label many songs share these attributes and having one place for them helps with data integrity the biggest difference here is how the tables are determined there are different pros and cons to these three examples I've shown the next chapter on normalization and D normalization will expand on this from the prerequisites you should be familiar with the relational model dimensional modeling is an adaptation of the relational model specifically for data warehouses it's optimized for OLAP type of queries that aim to analyze rather than update to do this it uses the star schema in the next chapter we'll delve into that more as we will see in the next slide the schema of a dimensional model tends to be easy to interpret and extend this is a big plus for analysts working on the warehouse dimensional models are made up of two types of tables fact and dimension tables what the fact table holds is decided by the business use case it contains records of a key metric and this metric change is often fact tables also hold foreign keys to dimension tables dimension tables hold descriptions of specific attributes and these do not change as often so what does that mean let's bring back our example when we're we're in analyzing songs the turquoise table is a fact table called songs it contains foreign keys to purple dimension tables these dimension tables expand on the attributes of a fact table such as the album it's in and the artist who made it the record in fact tables often change as new songs get inserted albums labels artists and genres will be shared by more than one songs hence records and dimension tables won't change as much summing it up to decide the fact table in a dimensional model consider what is being analyzed and how often entities changed let's do some X
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from DataCamp · DataCamp · 57 of 60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
▶
58
59
60
SQL Server Tutorial: Date manipulation
DataCamp
R Tutorial: Intermediate Interactive Data Visualization with plotly in R
DataCamp
R Tutorial: Adding aesthetics to represent a variable
DataCamp
R Tutorial: Moving Beyond Simple Interactivity
DataCamp
Python Tutorial: Why use ML for marketing? Strategies and use cases
DataCamp
Python Tutorial: Preparation for modeling
DataCamp
Python Tutorial: Machine Learning modeling steps
DataCamp
R Tutorial: The prior model
DataCamp
R Tutorial: Data & the likelihood
DataCamp
R Tutorial: The posterior model
DataCamp
R Tutorial: An Introduction to plotly
DataCamp
R Tutorial: Plotting a single variable
DataCamp
R Tutorial: Bivariate graphics
DataCamp
Python Tutorial: Customer Segmentation in Python
DataCamp
Python Tutorial: Time cohorts
DataCamp
Python Tutorial: Calculate cohort metrics
DataCamp
Python Tutorial: Cohort analysis visualization
DataCamp
R Tutorial: Building Dashboards with flexdashboard
DataCamp
R Tutorial: Anatomy of a flexdashboard
DataCamp
R Tutorial: Layout basics
DataCamp
R Tutorial: Advanced layouts
DataCamp
Python Tutorial: Time Series Analysis in Python
DataCamp
Python Tutorial: Correlation of Two Time Series
DataCamp
Python Tutorial: Simple Linear Regressions
DataCamp
Python Tutorial: Autocorrelation
DataCamp
R Tutorial: The gapminder dataset
DataCamp
R Tutorial: The filter verb
DataCamp
R Tutorial: The arrange verb
DataCamp
R Tutorial: The mutate verb
DataCamp
R Tutorial: What is cluster analysis?
DataCamp
R Tutorial: Distance between two observations
DataCamp
R Tutorial: The importance of scale
DataCamp
R Tutorial: Measuring distance for categorical data
DataCamp
Python Tutorial: Plotting multiple graphs
DataCamp
Python Tutorial: Customizing axes
DataCamp
Python Tutorial: Legends, annotations, & styles
DataCamp
Python Tutorial: Introduction to iterators
DataCamp
Python Tutorial: Playing with iterators
DataCamp
Python Tutorial: Using iterators to load large files into memory
DataCamp
SQL Tutorial: Introduction to Relational Databases in SQL
DataCamp
SQL Tutorial: Tables: At the core of every database
DataCamp
SQL Tutorial: Update your database as the structure changes
DataCamp
Python Tutorial: Classification-Tree Learning
DataCamp
Python Tutorial: Decision-Tree for Classification
DataCamp
Python Tutorial: Decision-Tree for Regression
DataCamp
Python Tutorial: Census Subject Tables
DataCamp
Python Tutorial: Census Geography
DataCamp
Python Tutorial: Using the Census API
DataCamp
R Tutorial: A/B Testing in R
DataCamp
R Tutorial: Baseline Conversion Rates
DataCamp
R Tutorial: Designing an Experiment - Power Analysis
DataCamp
R Tutorial: Introduction to qualitative data
DataCamp
R Tutorial: Understanding your qualitative variables
DataCamp
R Tutorial: Making Better Plots
DataCamp
SQL Tutorial: OLTP and OLAP
DataCamp
SQL Tutorial: Storing data
DataCamp
SQL Tutorial: Database design
DataCamp
Python Tutorial: Introduction to spaCy
DataCamp
Python Tutorial: Statistical Models
DataCamp
Python Tutorial: Rule-based Matching
DataCamp
More on: Data Literacy
View skill →Related AI Lessons
⚡
⚡
⚡
⚡
The Nervous System of the Telco: Unlocking the Real-Time Power of the Network Element Interfaces…
Medium · Data Science
Enhanced RFM Analysis for Customer Segmentation using K-Prototypes
Medium · Machine Learning
One Survey Asked Rich People Ten Times More Often Than Poor People.
Medium · Data Science
Data Cleaning Fundamentals: Building a Reproducible Data Cleaning Pipeline
Medium · Data Science
🎓
Tutor Explanation
DeepCamp AI