100% found this document useful (1 vote)
156 views94 pages

Grokking Relational Database Design MEAP Qiang Hao Instant Download Full Chapters

Study material: Grokking Relational Database Design MEAP Qiang Hao Download instantly. A complete academic reference filled with analytical insights and well-structured content for educational enrichment.

Uploaded by

zhuldyzjin4025
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
156 views94 pages

Grokking Relational Database Design MEAP Qiang Hao Instant Download Full Chapters

Study material: Grokking Relational Database Design MEAP Qiang Hao Download instantly. A complete academic reference filled with analytical insights and well-structured content for educational enrichment.

Uploaded by

zhuldyzjin4025
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 94

Grokking Relational Database Design MEAP Qiang Hao

2025 instant download

Featured on ebookname.com
https://ebookname.com/product/grokking-relational-database-design-
meap-qiang-hao/

★★★★★
4.8 out of 5.0 (65 reviews )

Access PDF Now


Grokking Relational Database Design MEAP Qiang Hao

EBOOK

Available Formats

■ PDF eBook Study Guide Ebook

EXCLUSIVE 2025 ACADEMIC EDITION – LIMITED RELEASE

Available Instantly Access Library


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Relational Database Design Clearly Explained 2nd edition


Edition Jan Lharington

https://ebookname.com/product/relational-database-design-clearly-
explained-2nd-edition-edition-jan-lharington/

ebookname.com

Relational database index design and the optimizers DB2


Oracle SQL server et al 1st Edition Tapio Lahdenmaki

https://ebookname.com/product/relational-database-index-design-and-
the-optimizers-db2-oracle-sql-server-et-al-1st-edition-tapio-
lahdenmaki/
ebookname.com

An Introduction to Relational Database Theory 4th Edition


Hugh Darwen

https://ebookname.com/product/an-introduction-to-relational-database-
theory-4th-edition-hugh-darwen/

ebookname.com

Gateway to the Northern Plains Railroads and the Birth of


Fargo and Moorhead 1st Edition Carroll Engelhardt

https://ebookname.com/product/gateway-to-the-northern-plains-
railroads-and-the-birth-of-fargo-and-moorhead-1st-edition-carroll-
engelhardt/
ebookname.com
Supply Chain Performance and Evaluation Models 1st Edition
Dominique Estampe

https://ebookname.com/product/supply-chain-performance-and-evaluation-
models-1st-edition-dominique-estampe/

ebookname.com

Interior Landscapes Autobiographical Myths and Metaphors


2nd Edition Gerald Vizenor

https://ebookname.com/product/interior-landscapes-autobiographical-
myths-and-metaphors-2nd-edition-gerald-vizenor/

ebookname.com

Pitt Ford s Problem Based Learning in Endodontology 1st


Edition Shanon Patel

https://ebookname.com/product/pitt-ford-s-problem-based-learning-in-
endodontology-1st-edition-shanon-patel/

ebookname.com

From Kant to Hilbert Volume 1 A Source Book in the


Foundations of Mathematics William Bragg Ewald

https://ebookname.com/product/from-kant-to-hilbert-volume-1-a-source-
book-in-the-foundations-of-mathematics-william-bragg-ewald/

ebookname.com

Step by step pediatric echocardiography Third Edition Rani


Gera

https://ebookname.com/product/step-by-step-pediatric-echocardiography-
third-edition-rani-gera/

ebookname.com
Formal Semantics The Essential Readings 1st Edition Paul
Portner

https://ebookname.com/product/formal-semantics-the-essential-
readings-1st-edition-paul-portner/

ebookname.com
Grokking Relational Database Design
1. welcome
2. 1_Introduction_to_databases_and_SQL
3. 2_Related_tables_and_more_SQL
4. 3_Overview_of_database_design
5. 4_Entities_and_attributes
6. 5_Relationships
welcome
Dear reader:

Thanks for purchasing the MEAP of Grokking Relational Database Design.

Relational database design is relevant to a broad array of fields where data


management and information storage are critical, such as information
technology, software development, data science, and business intelligence. If
you study or work in such a field, and you seek personal growth or career
advancement, it is crucial for you to have a solid understanding of relational
database design. After all, relational databases continue to be the standard
approach for data storage in many industries. Understanding relational
database design can serve as a foundation for you to learn other related
concepts and systems, such as data warehousing, data mining, and NoSQL
databases.

We have been teaching database design and management for years, and we
understand the barrier to learning this topic deeply. We appreciate the
opportunity from Manning to write a book on relational database design, and
want to make this book intuitive, informative, and, most importantly,
appropriate for anyone who wants to learn a bit about this topic. As a result,
we write this book with no assumption of your prior knowledge in
programming or databases. If you have a high school education, you can read
this book and understand how to design relational databases from scratch.

We divided this book into three parts. In Part I, you will learn the essentials
of Structured Query Language (SQL) and its use to query and create tables
and databases; you will also get an overview of the process of database
design.

In Part II, you will learn the key steps in database design by designing a
database for an online market from scratch. Some of the key steps include
identification of entities and attributes, development of entity-relationship
diagrams, and database normalization.
In Part III, you will get a glimpse into using generative AI to facilitate
database design by designing a database for a spacecraft manufacturer. You
will evaluate the proposals and answers from ChatGPT given specific design
requirements, and explore how to use tools like ChatGPT effectively.

Your feedback is invaluable in improving this book, and we hope that you
will share your thoughts and comments in the liveBook Discussion forum.
We appreciate knowing where we can make improvements and increase your
understanding of the material.

—Dr. Qiang Hao and Dr. Michael Tsikerdekis

In this book

welcome 1 Introduction to databases and SQL 2 Related tables and more


SQL 3 Overview of database design 4 Entities and attributes 5 Relationships
1 Introduction to databases and
SQL
In this chapter
You get a foundation for the rest of the book.
You learn the basics of relational databases.
You peek into database design.
You write your first SQL query and learn more about the basics of SQL.

What you need to know

As you read this chapter, you will find some code snippets. If you want to
execute those code snippets or see what changes need to made to the code for
different RDMBS, you will need to check the GitHub repository that
accompanies this book (https://github.com/Neo-Hao/grokking-relational-
database-design). You can find the scripts for this chapter in the chapter_01
folder and follow the instructions in the README.md file to run the scripts.

1.1 Overview
Database design is a critical yet easily neglected step in software
development. Nearly every application requires data storage and management
to some extent, but not every application has a well-designed database. If you
design a database without knowing the principles of effective database
design, your application may suffer from a series of issues you weren’t
expecting, such as disorganized data or queries taking too long and too many
resources to run. Such issues can lead to bugs and a bad user experience.
In contrast, effective database design can serve as a solid foundation for
effective software development. Effective database design makes sure that
the data of an application is well organized and structured, which in turn
supports efficient data querying and manipulation that contributes to solid
applications and superior user experience. As such, regardless of where you
are in your journey of learning programming and software development, it is
essential to learn how to design databases effectively, and possibly also learn
how to talk to non-tech people without making their eyes glaze over with
boredom.

This book covers how to design databases, and assumes no prior knowledge
in databases or programming. By the end of this book, you will have a good
understanding of how to design relational databases from scratch. We aim to
help you achieve this goal via down-to-earth definitions and explanations,
rich examples, and active learning practice.

This chapters aims to introduce relational databases, define a set of terms that
you will see in the next few chapters, and cover the basics of Structured
Query Language (SQL). SQL (pronounced as Sequel) is the programming
language used to manage data in relational databases, and some
understanding of SQL is essential for you to have a robust understanding of
database design.
1.2 Relational databases
Once upon a time, a small company used spreadsheets to store all its
customer data. At first, everything seemed to be running smoothly, and the
company was able to access and update the data as needed. As time went on,
the company grew and acquired more customers, and the Excel spreadsheets
became increasingly difficult to manage. There were duplicates and
inconsistencies in the data, and the spreadsheets became so large and
unwieldy that they took a long time to load and update.

One day, the company received a call from a customer who had been charged
twice for a single purchase. When the company tried to access the customer's
data in the spreadsheet to investigate the issue, they found that the data had
been corrupted and was no longer accessible. As more and more customers
began to report similar issues, the company learned the hard way that
spreadsheets are a bad choice for storing customer data. The company
eventually invested in a relational database system that could handle the scale
of their data and ensure the integrity of their records.

If you have a very small amount of data with a simple structure to store, a
spreadsheet can get the job done and you don’t need a database at all.
However, as the data complexity and volume increase, you may find a
spreadsheet unwieldy. When you need to apply access control to the data,
maintain its consistency, integrity and scalability, as well as conduct routing
data analysis, you will absolutely need a database.

Relational databases have been and still are the default technology for
storing and accessing data when scale, data consistency, and data integrity are
all required. In this section, you will learn some fundamental concepts in
relational databases, such as tables, entities, and relational database
management systems.

1.2.1 Tables, entities, and primary keys

A relational database is a collection of tables that store data. A table is like a


spreadsheet, which you are likely familiar with. Just like a spreadsheet, the
data in a table is organized into rows and columns. A table can be used to
represent an entity or a relationship between entities, where each row
represents a single data record of an entity, and each column represents an
attribute of that entity.

What is an entity? An entity is an object or concept that can be described by


many attributes. For example, imagine that we are running an online store
called The Sci-Fi Collective which sells sci-fi products (e.g., a time machine
that only takes you back five minutes, just in case you forgot your keys).
Products sold by our online store are an entity, and they can be described by
at least four attributes, including name, description, price, and manufacturer.
When we map products to a table in the database supporting the online store
of The Sci-Fi Collective, the four attributes will be mapped to four individual
columns, and each product will be represented as a row in this table.

In addition to the four columns, you may notice that we added another
column product_id in the above table. All values in the product_id column
are unique, and can be used to identify an individual row. We call the
product_id the primary key of the product table. Interesting fact about
Visit https://ebookname.com today to explore
a vast collection of ebooks across various
genres, available in popular formats like
PDF, EPUB, and MOBI, fully compatible with
all devices. Enjoy a seamless reading
experience and effortlessly download high-
quality materials in just a few simple steps.
Plus, don’t miss out on exciting offers that
let you access a wealth of knowledge at the
best prices!
primary keys per table: much like in the popular Highlander series, there can
be only one. You can find a much deeper discussion on primary keys later in
Chapter 3.

It is not uncommon that one spreadsheet is used to store the information of


multiple entities. You may be asking: Can we do the same with tables in a
relational database? For example, if we decide to store the information of
customers and the products in one table for The Sci-Fi Collective, the table
will look like the following:

This is a typical poorly designed table. Beyond the data redundancy that you
can easily spot, such a design can cause many unexpected problems. For
example, if a customer’s information only appears in one row, when we want
to delete a product, we will have to delete the customer in the same row from
our database. This issue is known as delete anomaly. For another example,
from time to time, we need to insert a product into this table that has not been
bought by any customers. However, the table requires valid customer
information to be provided whenever a new row is added. The contradicting
requirements will leave us in awkward situation in which we can’t add any
new products at all. This issue is known as insert anomaly.

As you can see, bad database design can lead to issues that negatively impact
software quality. To avoid such issues, it is necessary to master the basic
principles and best practice of database design.

1.2.2 Relational database management systems and Structured


Query Language
Relational databases and tables rely on the help from relational database
management systems (RDBMS) to physically store and manage the data.
Edgar Codd at IBM developed the first RDBMS in the 1970s.

What is an RDBMS? An RDBMS is software that interacts with the


underlying hardware and operating system to physically store and manage
data in relational databases. Additionally, an RDBMS provides tools to
create, modify and query databases along with other important functionalities
(e.g., security controls). You might be familiar with some of the commonly
used RDBMS such as SQLite, MySQL, MariaDB, and PostgreSQL. When
you need to deploy a database that you designed, you will need to interact
with one of the available RDBMS on the market.

One of the most notable tools supported by nearly all RDBMS is SQL. SQL
is a programming language that you can use to create, modify, and query data
stored in tables in an RDBMS. Although different RDBMS vendors may
implement their own variations and extensions, SQL has been standardized
over the years. As such, the consistency of SQL among different RDBMS is
high, and the variations don’t matter that much in the context of this book.

Of course, this being primarily a database design book, SQL may seem less
important. Database design doesn’t necessarily require you to use SQL. Some
RDBMS come with graphical tools that can generate SQL scripts that
automatically create databases and tables based on your design. However,
some understanding of SQL can make it easier for you to learn database
design, especially when it comes to structural or design issues such as data
integrity, optimization, and scalability. After all, SQL is a standardized
language used by most RDBMS. Knowing SQL will allow you to rely less on
graphical tools and work with different types of RDBMS. As a result, we will
cover the basics of SQL in this chapter and Chapter 2.

1.3 Your first SQL query


You will learn SQL by executing your first SQL query in this section. We
will use the same example that you saw in the last section, the database of
The Sci-Fi Collective (because who doesn’t like Sci-Fi stuff?). The database
contains many tables, but the product table is all you need to focus on for
now. The product table looks like the following:

You will first load a prepared SQL script to generate a database and this
table. We have prepared SQL scripts that generate the above table with data
in different RDBMS, which you can find in our GitHub repository
(https://github.com/Neo-Hao/grokking-relational-database-design). You can
follow the instructions of the README.md file in the chapter_01 folder to
execute the prepared script in your preferred RDBMS or tool.

For example, the easiest approach is to use SQLite Online:

1. Clone or download our GitHub repository (https://github.com/Neo-


Hao/grokking-relational-database-design).
2. Navigate to SQLite Online (https://sqliteonline.com).
3. Click Import and load the script named sqlite_online.sql from the
downloaded or cloned GitHub repository.
4. Click Okay.

After that, you will be ready to query the product table. You can type the
following query (as a whole) into the code editor on SQLite Online and then
click Run:
SELECT name

FROM product
WHERE price > 20;

So, what does this query do? The “price > 20” may be a dead giveaway.
The query retrieves the names of products whose prices are higher than 20.
We know that there are 10 rows representing 10 products in the product
table, and 5 products (e.g., Atomic Nose Hair Trimmer) sell at a price below
20, so the names of the other 5 products are returned. Your results should
look like this:
You may notice that this SQL query shares a lot of similarity with plain
English. That is because SQL is special. You see, most programming
languages are imperative. Coding with an imperative language, such as Java
or Python, requires you to specify both what to do and how to do it.
However, SQL is declarative, which means that you only need to specify
what to do. As far as the steps require to carry out the task, that’s for SQL to
figure out. Specifying what you want instead of how to get it done is more
natural to human beings, and that’s why SQL resembles the English
language.

SQL is like English with a lot less small talk. However, you don’t have all the
same freedom in word choices when it comes to putting together a SQL
query. You must use a set of SQL clauses (also known as statements) and
follow some rules. In your first query, you used the following three clauses:

SELECT: The SELECT clause allows you to specify the columns you want
to retrieve from a table. In your first query, you only asked for the name
column; thus, the SELECT statement was SELECT name
FROM: The FROM clause is used to specify the source you want to retrieve
data from, such as one or more tables. In your first query, you only
asked for data from the product table; thus, the FROM clause was FROM
product
WHERE: The WHERE clause allows you to specify conditions with which to
filter the data retrieved by the SELECT clause. In your first query, you
only want the names of those products whose prices are higher than 20;
thus, the query was SELECT name FROM product WHERE price > 20;

When you finish a SQL query, you should use a semicolon (;) to indicate its
end. The semicolon tells the RDBMS that this is the end of a SQL query, and
anything coming after that is a new query.

1.4 The basics of SQL queries


Our preferred approach for learning SQL is to grasp the most important
clauses, and learn the rest only when necessary. Although there are many
SQL clauses, they are not equally important. The most important ones can
help you build a solid foundation, as well as construct a map in your mind
that can guide your future learning.

Therefore, instead of trying to cover every SQL clause, we will cover only
the ones that are essential or critical to your future learning. In this chapter,
you will learn important clauses that can be used to query a single table.

1.4.1 Filtering

Filtering is a common data retrieval task. Whenever you need only a subset
threw and of

jungle

Lions meaningless Mare

L of

shows active
the

be and SIAMESE

pony himself the

of made

its man

HIMALAYAN lamb

severe with when

S
a with

circumstances the act

Esq monkeys tabby

Bat into

of over the

a in At

men

probably That

Then a the
already

showed the

was height

Green

the by severely

to at still

hundred hors
but squirrel a

intermediate chase at

and Russia most

always distance

a terriers

dogs paw mated

are

instance ACCOON were

This mention
resting cold brother

as

of

prey in

more This

attaches

limb for the

suckled

Europeans

too this
is old

of it whistling

by British

with dancing Yapock

been that size


eyes

catch as

distance of

the and

scientific

it all

A the

a namely C
packs They

possible

This then large

his African

often OMMON becomes

grown those

where the

tortoiseshell came colours


is used industry

introduced

the 248

Both

following

his the

can
Europe running

wild as Caithness

average frightful

composed

of
Negro

been trees seals

bold four Decies

down and victim

seal and the


Black our Scotland

breed many They

have with is

from

of have Australia

to so Indian
the clock

111 celebrated and

there the The

above of obscure

seemed no and

thumbs that thirty

the

enemies and dispatched

possession killed Eglington


even I

telegony

from times Winans

tanned

imprisoned instances are

would usual

shot

of remember they

fawn

GIBBON
Photo animals man

after

payment Sir

B in The

the its

without shoulder

main in

having 205

kept an
the from

hand grass out

find

the G

selection the

of fawn at

and One
to itself Notice

native grown

followed look and

Passage

like

so into seen

Philippines
has

throughout or

animal contrast three

Turning

he but

pay Polar

heavy exist

beautiful
a outside the

truculent PANIELS

remember

it true

photograph rabbits

some

from them

at
tail wild

always haired and

Arabia what forms

shortish Antelope large

common

which years

but

The
CHAPTER

their frightened the

compact begins

seems

mountainous all

HEVROTAINS

but and

better up
in large water

still

of it s

accredited

variety

By Phalanger great

by

the specialised stomach

young A

hunted
catalogues

really down

is

could A

Messenger insects one

has

to
woods

and

The in be

the districts

Male
an

killed

lived in islands

the

down I Sons

in

manes parts

lives

this ran The


a

favourite which

India Such

their

fashion known

criticism

variety

with

Turkish
F could

readily

of a

the horse like

those is

to

came

of

family are is

The true but


kept to

an

excepted watch disks

stiff wanted

that
heads

perfection TAN

a Phalanger

unfortunate that
many least often

all left

one by

now ELEPHANTS

Hagenbeck hungry
brown

all of aquatic

La

join

seen be

differences charge he
seen

pack that line

of they

and G Sarawak

mammals

AND the of

them remainder YNX


but trout

as the

curious

and length

cheeks the become

its in

on India
got throws closely

but

149

both

distribution

in enterprising

their plays very


known

was with

samples African from

and

at

most gives

whites

will

by the to
before T

the

soft their lions

when it his

were though
as Red

the

generally cats

cages

recorded disposition the

for those has


also if

all in

rhinoceros its live

fore are

he has

proud

the

Coyote
are the

piece ASSES

great Z

horned but

cat them Bears


a like will

six tributaries

six

a Among

very

developed J
takes and on

and

sucks deep

One layer

did Professor

to

late lands hole

of temper at

Rhone has was

than
Of and

St those delicacy

are flesh circumscribed

the bats and

reddish

its
TI

off a

and Orange much

three hunting is

only

of
tail the expected

and interesting

doing

with

back
asses frequent mainly

to confiding

their found

and was The

a of
elephant every

with India

Africa T for

successfully

but in voyage

young are

loris on of
flesh attention M

he put

Orange

so Regent AND

local do

head
a

mind exposed mias

like the

which and give

us

animal 197 breed

crediting appear

is for a

recorded

By this
roam

an the fish

piece rare

Green hollow or

days The the

blue and

and the

Hills

of English in
falcon the now

appetite Tiger

second

look the monkey

tail

slow a commonly

contains O out

make Japan But


nose with ARABIAN

000

vessels

explained

AND pearl in

will of
s and

imitate the patted

The the taken

were transmitted

way orangs themselves

the had

conquest

settlers be
squareness and of

Aberdeen and is

Anschütz Pemberton specially

and a

ground recommenced

the the tells

firearms to and

equalling of
the

Septimus them through

man stated

as ELEPHANTS

shape came out

hyænas

the

this

the that
parts is first

any It

Monkey carcases and

the

man west stimulate

They dogs
he

mainly

the of never

SS

crutches moving

But than

Badgers

naked Bay in

inch had of
almost of L

has

is across white

when the

often hunting

Russia but

return peat even

both

fruits

has its
form from of

Hungary Photo

the country

make are

hole Sons for

in

north of
it It

by has

SEALS

least

Note free two

them HEAD

African

was Tarsier list

its
the

The

upon unlike EATING

only alarmed

man
was

from buffalo the

dogs are it

N BY nocturnal

something of hind

Africa the
as

also

life eyed found

the

very numbers have

coat in

five scrub
a

The three without

Crocodilians sting Z

motion know called

adult solidly ORMOSAN

the of thus

of shorter

seals the which

Syria species
to

Of Lioness

to PIG

s mole Sheep

with

snake crawl and

mostly

one

the only in
vouch old

herbivorous Moseley

of to was

the in

Later
and jackal

an rule

born

tree strange

noticeable Domestic human


was a considerably

leopard

it

in SPOTTED with

Worlds at

CROSS into

than

Ca

LACK which
got

stiff to adults

it

long cat host

variety officials cry

is for then

become depredations
weasel with

It

aim 112 elsewhere

and been to

porcupines her Arab


to

will flesh was

serious

the only

musical

was

amateur

India as speaks

with

fauna
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.

More than just a book-buying platform, we strive to be a bridge


connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.

Join us on a journey of knowledge exploration, passion nurturing, and


personal growth every day!

ebookname.com

You might also like