database design 1 - trinity...
TRANSCRIPT
1
Dr. Tom HicksComputer Science Department
Database Design 1
University Library
Software EngineeringCSCI-3321
2
Student-Database-Design-1.xlsx
RenameTomH-Database-Design-1.xlsx
Using Your First & Initial
Part Of Today's In-Class Lab Will Be To Submit This SpreadSheet
3
Student-Database-Design-1.docx
RenameTomH-Database-Design-1.docx
Using Your First & Initial
Part Of Today's In-Class Lab Will Be To Submit This Completed Pledge
Form
4
Import UniversityA
use universitya
5
Import UniversityA1 - How Many Tables In Our University Library?
2 - How Many Records In Table Book?
6
Book Two Major Design
Flaws
Not Looking For Additon Data Members Yet
7
Form Small Group 2 (if possible 2 - else 3)
Work In Class Today As A Team!
8
Two Major Design Flaws Show The Book Table Layout!
4 - List The Two Major Design Flaws With Books?
9
Import universitya
1 - A Book May Have More Than One Genre
4 - List The Two Major Design Flaws With Books?
2 - A Book May Have More Than One Author
10
Table Genre
1 - We Now Need A Relationship/Table To Tie These Together!
11
Add Tables BookGenre & Genre
1 - We Use Arrows To Represent The Relationships
Good Design Is Good Design This Is The Best Approach For Direct Access Files, Text Files, ISAM Files, etc.
12
Small Group 2 (Answer As Many As You Can In 90 Sec)
Lots Of Design Advantages Let's Work At Organizing & Extracting The Data Properly
13
Attack First Problem:
A Book May Be Associated With More
Than One Genre
14
Import UniversityB
use universityb
15
Import Database UniversityB 6 Tables
1 - Before We Join Small Tables, I Have Found It Beneficial To Join Some Tiny Tables.
16
Table A
1 - Show All The Data Members In Table A
17
Table B
1 - Show All The Data Members In Table B
18
Table C
1 - Show All The Data Members In Table C
19
Execute This Query
A B
SELECT * FROM A,B;
20
SELECT * FROM A, B B, A
SELECT * FROM A,B; SELECT * FROM B,A;
A B
NOT COMMUTATIVE!
21
Small Group 2 (Answer As Many As You Can In 60 Sec)
22
DatabaseJoins
Relationship Spans
23
Database Joins Relationship Spans
Databases Have Support A Number Of Different Joins.
Cross JoinsNatural JoinsInner JoinsOuter JoinsEtc.
Not All Databases Support All Of The Joins
We Are Not Going To Do These Joins I Hope You Take The Database Class I Have Been Told That Many Of Our Database
Optimizers Will Replace Your Relationship Spans
We Are Going To Concentrate On Some Basic Relationship Spans
24
"C++" Relationship Spans
25
Book, BookGenre
26
Suppose We Have A Query FROM Book, BookGenre
27
BookGenre, Genre
28
Suppose We Have A Query FROM BookGenre, Genre
29
Book, BookGenre, Genre
30
Suppose We Have A Query FROM Book, BookGenre, Genre
31
Potential ProblemWith
Relationship Spans
32
The Relationship Span, Without The Relationship Link, Generates A Lot Of Meaningless Records
Execute The Following Query:
SELECT Title, Price, Book.ID AS "Book.ID", BookID As "BookGenre.ID"
FROM Book, BookGenre;
The First 4 Records Are Meaningless:Book.ID != BookID
33
The Relationship Link
SELECT Title, Price, Book.ID AS "Book.ID", BookID As "BookGenre.ID"
FROM Book, BookGenreWHERE Book.ID = BookID;
Execute :
34
Filter Out The Duplicate Records
Execute :
SELECT Distinct Title, Price, Book.ID AS "Book.ID", BookID As "BookGenre.ID"
FROM Book, BookGenreWHERE Book.ID = BookID;
35
Why Did We Get The Duplicate Records?
SELECT Title, Price, Book.ID AS "Book.ID", BookID As "BookGenre.ID", GenreID
FROM Book, BookGenreWHERE Book.ID = BookID;
7 Different Genre Associated With Data Communications Text
36
Small Group 2 (Answer As Many As You Can In 45 Sec)
37
Small Group 2 (Answer Now)
Meaningless
SELECT … FROM TableA, TableB
38
Query Practice I
use universityb
39
Create TomH-Database-Design-1-Queries.txt
We are going to do several Queries Open Notepad ++
You Will Probably Not Be Able To Get All Of The Queries, But Do As Many As You Can.
40
SELECT Title, PriceFROM BookWHERE
SELECT Title, Price, GenreIDFROM Book, BookGenreWHERE (GenreID = 180)
Query 1
Display The Title, Price & GenreID Of All The Books Whose GenreID = 180
SELECT Title, Price, GenreIDFROM Book, BookGenreWHERE (GenreID = 180) AND (BookID = Book.ID);
41
Small Group 2 (Answer Now)
42
Small Group 2 (thoughts)
Placing your queries in NotePad ++ May Well Prove Helpful!
43
SELECT COUNT(*)FROM BookGenreWHERE GenreID = 62;
Query 2
Display The No Books Whose GenreID = 62
Combine Only Enough Tables To
Solve The Problem!
44
SELECT Book.ID, Title, GenreIDFROM Book, BookGenreWHERE (GenreID = 62) AND (BookID = Book.ID);
Query 3
Display The Book ID, Titles & GenreID WhoseGenreID = 62
45
SELECT Genre.ID, Description, BookIDFROM Genre, BookGenreWHERE (BookID = 86) AND (GenreID = Genre.ID);
Query 4
Display The Genre ID, Description, & Book ID Whose Book ID =86
46
SELECT Title, Book.ID, BookID, GenreID, Genre.ID, Description
FROM Book, BookGenre, GenreWHERE (BookID = Book.ID) AND
(GenreID = Genre.ID);
Execute Query 5
47
SELECT Description AS GenreFROM Book, BookGenre, GenreWHERE (BookID = Book.ID) AND
(GenreID = Genre.ID) AND (Title = "Vector Calculus");
Query 6
Display All of the Descriptions, called "Genre", that are associated with Vector Calculus.
48
SELECT Title AS "Technology Titles"FROM Book, BookGenre, GenreWHERE (BookID = Book.ID) AND
(GenreID = Genre.ID) AND(Description = "Technology");
Query 7 Display All of The Titles, called "Technology
Titles", that are associated with Technology.
49
Attack Second Problem:
A Book May Be Associated With More
Than One Author
50
Modify The Class Diagram 1 Minute More Than One Author.
51
Class Diagram Add Tables BookAuthor & Author More Than One Author.
52
Import UniversityC
use universityc
53
Examine Database UniversityC
Author Has How Many Data Members …….._____ Author Has How Many Records …………… _____
Book Has How Many Data Members........... _____ Book Has How Many Records …………….. _____
BookAuthor Has How Many Data Members _____ BookAuthor Has How Many Records …….. _____
85
54
84
SELECT *FROM Book, BookAuthor, Author
Data Members = ________Records ….…. = ________
13320
No Pieces Of Info = _____________4,160
54
DatabaseRelationship Spans
55
"Physics Volume 1" Relationship Spans
56
Query Practice II
use universityc
57
Query 8
Display The Number Of Authors That Are Associated With Physics Volume I
SELECT COUNT(*)FROM Book, BookAuthorWHERE (Title = "Physics Volume 1") AND
(BookID = Book.ID);
58
Query 9
Display All Of The Author & BookAuthorInformation About Book ID 86.
SELECT *FROM Author, BookAuthorWHERE (BookID = 86 ) AND
(AuthorID = Author.ID);
59
Query 10
Display The Author's full name and Author ID For The Authors Of Book ID 86.
SELECT Author.ID, FullNameFROM Author, BookAuthorWHERE (BookID = 86 ) AND
(AuthorID = Author.ID);
60
Query 11
Display Book ID, Titie, FullName (alpha order), Author ID Of "Beginning Software Engineering"
SELECT Book.ID, Title, FullName, Author.IDFROM Author, BookAuthor, BookWHERE (BookID = Book.ID) AND
(Title = "Beginning Software Engineering" )AND (AuthorID = Author.ID)
ORDER BY FullName;
61
Import UniversityD
use universityd
62
Examine Database UniversityD Tiny To Small ANSWER #25
Genre Has How Many Data Members …….._____ Genre Has How Many Records …………… _____
Book Has How Many Data Members........... _____ Book Has How Many Records …………….. _____
BookGenre Has How Many Data Members _____ BookGenre Has How Many Records …….. _____
2023
1005
2564
SELECT *FROM Book, BookGenre, Genre
Data Members = ________Records ….…. = ________
125,171,200
No Pieces Of Info = _____________62,054,400
63
SELECT Title AS "Engineering Titles"FROM Book, BookGenre, GenreWHERE (BookID = Book.ID) AND
(GenreID = Genre.ID) AND(Description = "Engineering");
Query 12 - 1 Display All of The Titles, called "Engineering
Titles", that are associated with Engineering Order By Title,.
64
Query 12 - 2 Pulled Data From 62,054,400 Info "Engineering Titles"
65
Examine Database UniversityD Tiny To Small ANSWER #26
Author Has How Many Data Members …….._____ Author Has How Many Records …………… _____
Book Has How Many Data Members........... _____ Book Has How Many Records …………….. _____
BookAuthor Has How Many Data Members _____ BookAuthor Has How Many Records …….. _____
1665
1005
1624
SELECT *FROM Book, BookAuthor, Author
Data Members = ________Records ….…. = ________
142,689,200
No Pieces Of Info = _____________37,648,800
66
Query 13
Display Book ID, Titie, FullName, Author ID Of " Automated Software Testing: Introduction, Management, and Performance " Order ByFullName
SELECT Book.ID, Title, FullName, Author.IDFROM Author, BookAuthor, BookWHERE (Title = "Automated Software Testing:
Introduction, Management, and Performance" ) AND (BookID = Book.ID) AND (AuthorID = Author.ID)
ORDER BY FullName;
67
Query 13 - 2 Pulled Data From 37,648,800 Info
68
User Four Major Design
Flaws
Not Looking For Additon Data Members Yet
69
Four Major Design Flaws Select First In Order From Top
70
Design Flaw One DeptName
71
Why DeptID 1 (2 min)
A new dept might be Added Changed, or Deleted This can be accomplished by providing the administrative users with an interface to Add, Edit, Delete departments. This can be done without revising the code.
The choices can be placed in a combobox control The use would not have to Know all of the Choices.
The choices can be placed in a combobox control The use would not have to know how to Properly Spell all of the Choices.
72
Why DeptID 2
The Dept might become a User Sub-System Filter Doing this with numerical values would prove faster in the selection.
The Dept might become a User Sub-System Order ByDoing this with numerical values would prove faster in the selection.
Some E-Mails, Texts, & Reports Might Be Done For A Single Dept Doing this with numerical values would prove faster in the selection.
73
Why DeptID 3
The Dept might become a User Sub-System Filter Doing this with numerical values would prove faster in the selection.
The Dept might become a User Sub-System Order ByDoing this with numerical values would prove faster in the selection.
Some E-Mails, Texts, & Reports Might Be Done For A Single Dept Doing this with numerical values would prove faster in the selection.
Some E-Mails, Texts, & Reports Might Be Done For ALL Depts Doing this with numerical values would prove faster in the selection.
74
Why DeptID 4
If you used both Dept & UserDept then folks could be associated with multiple depts they should not ever place two depts in the one text box.
When we get to indexing, we will find several real speed advantages of either partition.
I am sure there are other advantages!
75
28
76
Four Major Design Flaws Select Second In Order From Top
77
Four Major Design Flaws Select Second In Order From Top
78
Four Major Design Flaws Select Third In Order From Top
79
Four Major Design Flaws Select Third In Order From Top
80
Four Major Design Flaws Select Fourth In Order From Top
81
Four Major Design Flaws Select Fourth In Order From Top
82
Update User & BookClass Diagrams
TomH-Database-Design-1.xlsx
83
Complete TomH-Database-Design-1.xlsx - 36
84
Update User & BookClass Diagrams
TomH-Database-Design-1.xlsx
85