Step
2
Removing
Redundant Data from the Database
We first split the 2-column list of titles
and authors into two lists,
one list of titles and another list of authors.
This removed a lot of redundant and
wasted storage space,
but now requires that we “join” the two lists back together.
This will create the logical
relationship between both lists
that was lost when they were split apart, in the next step.
Here we simply number the titles and the
author names,
that will be used to re-connect the authors with their book titles
that will be done in the next step.
|
TitleNo |
Titles |
|
AuthorNo |
Authors |
|
1 |
Lost
Worlds of 2001 |
|
1 |
Arthur C.
Clarke |
|
2 |
Childhood's
End |
|
2 |
Ayn Rand |
|
3 |
2001 : A
Space Odyssey |
|
3 |
Dan Brown |
|
4 |
2010 :
Odyssey Two |
|
4 |
David
Alexander |
|
5 |
2061 :
Odyssey Three |
|
5 |
Douglas
Adams |
|
6 |
3001 :
Final Odyssey |
|
6 |
Georges Simenon |
|
7 |
The Moon
Is a Harsh Mistress |
|
7 |
Isaac
Asimov |
|
8 |
A Fall of
Moondust |
|
8 |
Douglas Adams |
|
9 |
Breaking
Strain |
|
9 |
Joe Haldeman |
|
10 |
Maelstrom |
|
10 |
Douglas
Adams |
|
11 |
Hide and
Seek |
|
11 |
Michael
Crichton |
|
12 |
Tales
from Planet Earth |
|
12 |
Nella Parson |
|
13 |
Rendezvous
with Rama |
|
13 |
Richard
Prather |
|
14 |
Rama Revisited |
|
14 |
Robert
Heinlein |
|
15 |
Atlas
Shrugged |
|
15 |
Scott Turow |
|
16 |
Fountainhead |
|
16 |
Tony
Fiore |
|
17 |
Deception
Point |
|
|
|
|
18 |
Digital
Fortress |
|
|
|
|
. . . . . . |
|
|
|
|
|
|
|
|
||
|
51 |
For Us,
the Living |
|
|
|
|
52 |
Glory
Road |
|
|
|
|
53 |
Pleading
Guilty |
|
|
|
|
54 |
Burden of
Proof |
|
|
|
|
55 |
The
Corvair Decade |
|
|
|
Here, you may know that “Deception Point” (title number 17)
was written by Dan Brown (author number 3),
but the database has no idea of who wrote what.
This requires a “one-to-many”
relationship which simply means that
each “one author” wrote “many” books.
(Technically,
this means that each author may have written one or more books,
but could also be used if the author wrote no books at all.
In database terminology, the word “many” means from “zero to many.”
So, keeping this in mind, we will simply refer to it as “many.”)
Assigning
“Primary Keys” to the lists
The numbers that have been added to each
list
will be used to identify who wrote what book.
For now, it’s sufficient that the
numbers that we have assigned to each row in each list
help us to uniquely identify each row in each list.
Now is a good time to introduce the
database “table” :
The lists that are shown above are
tables – it’s that simple.
A “table” is simply another word for a
list,
and can have as many rows as there are items in the list, or “table.”
Each column in each table describes
something about the items in that list.