MySQL Query Lab III 25 Points

151
1 MySQL Query Lab III 25 Points MySQL TU Database 3343 Dr. Thomas Hicks

description

MySQL Query Lab III 25 Points. MySQL TU Database 3343 Dr. Thomas Hicks . You May Do This Lab On Your Own Personal Computer Or On Your Database System. Your Name _________________ Name This Presentation: Tom-Hicks-MySQL-Query-3.pptx {Substitute Your First & Last Names}. - PowerPoint PPT Presentation

Transcript of MySQL Query Lab III 25 Points

Page 1: MySQL Query Lab III 25 Points

1

MySQL Query Lab III25 Points

MySQLTU Database 3343

Dr. Thomas Hicks

Page 2: MySQL Query Lab III 25 Points

2

You May Do This Lab On Your

Own Personal Computer Or On Your Database

System

Page 3: MySQL Query Lab III 25 Points

Your Name

_________________

Name This Presentation:Tom-Hicks-MySQL-Query-3.pptx

{Substitute Your First & Last Names}

Page 4: MySQL Query Lab III 25 Points

Computer Used Is

_________________

{My Personal Computer or CS-??}

Page 5: MySQL Query Lab III 25 Points

5

Your Slide Presentation Should

Include Screen Captures That Are Cropped – Clear &

Easy To Read

Page 6: MySQL Query Lab III 25 Points

6

If This Bar Is Light Blue – It Is Info That You Should Read!

Helpful HintThere Will Often Be A Colored Title Bar At The Top Of A Slide

If This Bar Is Red – You Will Have Screen Captures To Replicate And/Or Questions To Answer

If This Bar Is Green – You Will Have To Create Original Screen Captures And/Or Questions To Answer

Page 7: MySQL Query Lab III 25 Points

7

Use The Snippping Tool To Help You With Your Screen Captures

Use Both The Rectangular Snip & The Window Snip As Is Appropriate!

Page 8: MySQL Query Lab III 25 Points

8

Trying To Capture SHOW FIELDS Command:

Good!

Page 9: MySQL Query Lab III 25 Points

9

Use Good/Neat/Readable Captures Crop Your CapturesDon’t Include Extraneous Stuff! This Is Not Good!

BAD!

Page 10: MySQL Query Lab III 25 Points

10

SELECT …. First Line

FROM … Next Line

WHERE … Next Line If There

ORDER BY … Next Line If There

Use The Document Query Format For All Slides!

Document Query Format

Page 11: MySQL Query Lab III 25 Points

11

Use The MySQL Command Line

Client

Answer All QuestionsReplace Screen Captures

Page 12: MySQL Query Lab III 25 Points

The Basics Of SQL Are Generic

Many Implementations Of MySQL Offer Additional Enhancements

(i.e. MySQL Might Have A String Function, Or Mathematical Function, That Might Not Be

Available In MSSQL)

You Can Generally Add Your Own Custom Functions To Most SQL Environments.

Page 13: MySQL Query Lab III 25 Points

13

Your Slide Presentation Should

Include Screen Captures That Are Cropped – Clear &

Easy To Read

Page 14: MySQL Query Lab III 25 Points

14

If This Bar Is Light Blue – It Is Info That You Should Read!

Helpful HintThere Will Often Be A Colored Title Bar At The Top Of A Slide

If This Bar Is Red – You Will Have Screen Captures To Replicate And/Or Questions To Answer

If This Bar Is Green – You Will Have To Create Original Screen Captures And/Or Questions To Answer

Page 15: MySQL Query Lab III 25 Points

15

Trying To Capture SHOW FIELDS Command:

Good!

Page 16: MySQL Query Lab III 25 Points

16

Use The Snippping Tool To Help You With Your Screen Captures

Use Both The Rectangular Snip & The Window Snip As Is Appropriate!

Page 17: MySQL Query Lab III 25 Points

17

Use Good/Neat/Readable Captures Crop Your CapturesDon’t Include Extraneous Stuff! This Is Not Good!

BAD!

Page 18: MySQL Query Lab III 25 Points

18

SELECT …. First Line

FROM … Next Line

WHERE … Next Line If There

ORDER BY … Next Line If There

Use The Document Query Format For All Slides!

Document Query Format

Page 19: MySQL Query Lab III 25 Points

19

Use The MySQL Command Line

Client

Answer All QuestionsReplace Screen Captures

Page 20: MySQL Query Lab III 25 Points

The Basics Of SQL Are Generic

Many Implementations Of MySQL Offer Additional Enhancements

(i.e. MySQL Might Have A String Function, Or Mathematical Function, That Might Not Be

Available In MSSQL)

You Can Generally Add Your Own Custom Functions To Most SQL Environments.

Page 21: MySQL Query Lab III 25 Points

21

SQL

Structured Query Language

Page 22: MySQL Query Lab III 25 Points

22

ConfigureThe Command

Window

Page 23: MySQL Query Lab III 25 Points

23

Getting Ready To Change Window Properties

Using the mouse, Right Mouse Click On The Top Of The Window and Select Properties

Page 24: MySQL Query Lab III 25 Points

24

Set The Window Screen Text To WhiteSet Your Background To Red, Black, Green, Or Navy

Do Not Select Maroon Background

Page 25: MySQL Query Lab III 25 Points

25

Set The Window Properties As Illustrated Below

Page 26: MySQL Query Lab III 25 Points

26

Set The Window Screen Text To WhiteSet The Background To Red, Black, Green, Or Navy

Do Not Select Maroon Background

Page 27: MySQL Query Lab III 25 Points

27

Put File Library-Hicks.sql On Your DesktopShow The Size In General Properties

Page 28: MySQL Query Lab III 25 Points

28

LOADTHE

DATA

Page 29: MySQL Query Lab III 25 Points

29

Reload The Library-Hicks-1.sql

Page 30: MySQL Query Lab III 25 Points

30

Don't Necessarily Expect Your Output To Be Exactly Like Mine!

The Queries Will Work. Check Your Own Output!

Page 31: MySQL Query Lab III 25 Points

31

Start MySQL AdministratorConfigure & Login

Page 32: MySQL Query Lab III 25 Points

32

Select CatalogsMake Sure That Your Library Database Is Included In The List

Page 33: MySQL Query Lab III 25 Points

33

Select Restore. Select Another Schema. Select Your Library??Push Open Backup File

Page 34: MySQL Query Lab III 25 Points

34

Select Library-Hicks.sql From The Desktop

Page 35: MySQL Query Lab III 25 Points

35

Start The Restore

Page 36: MySQL Query Lab III 25 Points

36

Close

Page 37: MySQL Query Lab III 25 Points

37

Select/Open A

Database

The Open Database Is Often Called The Default Database

Page 38: MySQL Query Lab III 25 Points

38

All Of The Fields In Your Database Will Match Those In My Database 100%

I Reserve The Right To Use Slightly Different Data In An Effort To Ensure That You Carefully Examine Your Own Queries!

All Of The Relationships In Your Database Will Match Those In My Database 100%

All Of The Table & Field Names Will Match 100%

Page 39: MySQL Query Lab III 25 Points

39

Show All Databases On Your System. Open Your Library?? Database. Only One Database May Be Open At A Time.

Replace The Capture Below!

Page 40: MySQL Query Lab III 25 Points

40

Display TheDatabase

Tables

Show Tables (Open Database)

Page 41: MySQL Query Lab III 25 Points

41

Show All Tables In The Open Database.Replace The Capture Below!

Page 42: MySQL Query Lab III 25 Points

42

Display TheDatabase Table

Layout

(Fields, DataTypes, Etc.)

Page 43: MySQL Query Lab III 25 Points

43

1] Open Your Library?? Database2] Display The Tables In The Open Database3] Show The Table Layout For Users Include The Capture Below!

Page 44: MySQL Query Lab III 25 Points

44

1] Show The Table Layout For TeamMembers Include The Capture Below!

Page 45: MySQL Query Lab III 25 Points

45

UNION

Page 46: MySQL Query Lab III 25 Points

46

Display A Query List, Called Names, That Contains All Of The User First Names And All Of The Server TeamNames.

Replace The Capture Below!

Page 47: MySQL Query Lab III 25 Points

47

Users & Teams

Start To Form A Relationship

Page 48: MySQL Query Lab III 25 Points

48

A User May Be A Member Of One Or More Teams. Teams Shall Be A Relationship Between The Users & The Servers. This Will Be Explained More Later In The Presentation.

Page 49: MySQL Query Lab III 25 Points

49

Entity-Relationship

E-R Diagrams

Page 50: MySQL Query Lab III 25 Points

50

Do The Following Google Search

Page 51: MySQL Query Lab III 25 Points

51

Replace The Capture Below!

Google Had About _____________________________________ Results For This Search.

Page 52: MySQL Query Lab III 25 Points

52

Go To The Wikipedia Entry. Read It Completely.As Always, The Things You Read In Your Homework Should Be Included In The List Of

Things You Study For Your Exam/Quizzes. Print Them If You Like.Replace The Capture Below!

Page 53: MySQL Query Lab III 25 Points

53

Entity

In Your Own Words: “What Is An Entity?”

An Entity Is _______________________________________________________________

_________________________________________________________________________Suppose We Had Two Entities: Computer & Programmer. Include Two Sketches/Diagrams (Below) To Represent These Entities:

Page 54: MySQL Query Lab III 25 Points

54

Relationship

In Your Own Words: “What Is An Relationship?”

A Relationship Is _________________________________________________________

_________________________________________________________________________

Suppose We Had Two Entities: Computer & Programmer. Suppose The Relationship Between The Computer And The Programmer Was Called Program. Include An E-R Diagram Below To Represent This Relationship.

Entity-relationship diagrams don't show single entities or single instances of relations. Rather, they show entity sets and relationship sets.

Page 55: MySQL Query Lab III 25 Points

55

Attribute

In Your Own Words: “What Is An Relationship?”

An Attribute Is _________________________________________________________

_________________________________________________________________________

Suppose We Had An Entities: Company (whose Attributes Are Name, BusinessType, Owner, ID, and Phone. Sketch The E-R Diagram For Company (Always include the attributes)

Page 56: MySQL Query Lab III 25 Points

56

Extended E-R Features & Primary KeyThere Have Been Several Extensions Since The Original Chen Publication

Some Programmers Underline Those Attributes That Form The Primary Key – Some Use A Double Ellipse

http://www.sis.pitt.edu/~valeriab/1022-spring08/Chapter6.pdf

Page 57: MySQL Query Lab III 25 Points

57

E-R With An ISA

Page 58: MySQL Query Lab III 25 Points

58

Questions #1 – Use Red Ink For Your Answers1] _____________________________ _____________________________ ER is an acronym for _?_

2] A_____________________________ C_____________________________ In software engineering, an entity-relationship model is an _?_ and _?_ representation of data.

3] D_____________________________ Entity-relationship modeling is a D_?_ modeling method, used to produce a type of conceptual schema or semantic data model of a system, often a relational database, and its requirements in a top-down fashion.

4] P_____________________________ C_____________________________ The E-R Modeling Technique was developed By P_?_ C_?_ (LSU) in 1976.

5] _____________________________ Diagrams created with the E-R Model are called Entity-Relationship Diagrams, E-R diagrams, or _?_.

6] _____________________________ A(n) _?_ is something that has a distinct, separate existence, though it need not be a material existence; it may be a physical object such as a house or a car, an event such as a house sale or a car service, or a concept such as a customer transaction or order.

Page 59: MySQL Query Lab III 25 Points

59

Questions #2 – Use Red Ink For Your Answers7] I_____________________________ An entity-type is a category. An entity, strictly speaking, is an I_?_ of a given entity-type. There are usually many instances of an entity-type. Because the term entity-type is somewhat cumbersome, most people tend to use the term entity as a synonym for this term.

8] _____________________________ The symbol used to represent an entity in an E-R Model is a(n) _?_. 9] _____________________________ The part of speech often associated with an entity is the _?_. 10] Suppose the entity is an artist. Sketch the E-R diagram to represent this artist.

11] Suppose the entity is a song. Sketch the E-R diagram to represent this song.

12] _____________________________ A _?_ captures how two or more entities are related to one another.

Page 60: MySQL Query Lab III 25 Points

60

Questions #3 – Use Red Ink For Your Answers13] _____________________________ The symbol used to represent a relationship in an E-R Model is a(n) _?_.

14] _____________________________ The part of speech often associated with an relationship is the _?_.

15] Sketch the E-R Diagram for owns relationship between a company and a land. Land might be owned jointly between two companies.

16] Sketch the E-R Diagram for worksfor relationship between a company and a people. A person might work for two companies.

17]. _____________________________ Entities and relationships can both have _?_. Examples: an employee entity might have a Social Security Number (SSN).

Page 61: MySQL Query Lab III 25 Points

61

Questions #4 – Use Red Ink For Your Answers18] _____________________________ The symbol used to represent an attribute in an E-R Model is a(n) _?_.

19] _____________________________ The parts of speech often associated with an attribute are the _?_ and the _?_.

20] P_____________________________ K_____________________________ Every entity (unless it is a weak entity) must have a minimal set of uniquely identifying attributes, which is called the entity's P_?_ K_?_.

21] _____________ _____________ The E-R Diagram above has _?_ Entity and _?_ Attributes;

22] __________________________________________________List the fields/attributes that form the primary key for Account.

Page 62: MySQL Query Lab III 25 Points

62

Questions #5 – Use Red Ink For Your Answers

23] __________________________________________________List the fields/attributes that form the primary key for Employee (if any) 24] ______________________________Employee is a _?_ {Strong/Weak} Entity. 25] __________________________________________________List the attributes of Employee. 26] __________________________________________________List the attributes of Mechanic.

Page 63: MySQL Query Lab III 25 Points

63

Questions #5 – Use Red Ink For Your Answers

23] __________________________________________________List the fields/attributes that form the primary key for Employee (if any) 24] ______________________________Employee is a _?_ {Strong/Weak} Entity. 25] __________________________________________________List the attributes of Employee. 26] __________________________________________________List the attributes of Mechanic.

Page 64: MySQL Query Lab III 25 Points

64

Questions #6 – Use Red Ink For Your Answers

27] _______________________________________________________List the fields/attributes that form the primary key for Client (if any) 28] ______________________________Client is a _?_ {Strong/Weak} Entity. 29] _______________________________________________________List the attributes of Client. 30] _______________________________________________________List all of the Entities

Page 65: MySQL Query Lab III 25 Points

65

Questions #7 – Use Red Ink For Your Answers

31] _______________________________________________________List all of the Relationships 32] __________ {T/F} Relationships do not have attributes. 33] _______________________________________________________List the attributes of Sells.

Page 66: MySQL Query Lab III 25 Points

66

Do A Google Search For A Commercial Graphical SoftwarePackage Designed To Do E-R Diagrams

Include Both A Picture Of The Box & The PriceInclude The Screen Capture(s) Below!

Page 67: MySQL Query Lab III 25 Points

67

Entity-Relationship

E-R Diagrams

Page 68: MySQL Query Lab III 25 Points

68

Extra CreditFind A Free (Not Just A Trial) Graphical Software

Package Designed To Do E-R DiagramsInclude The URL & Title

Install On Your System – Open - Include The Screen Capture(s) Below!

Page 69: MySQL Query Lab III 25 Points

69

Table Users Has 8 Fields & 15 RecordsCreate An E-R Diagram For Users

Maybe Use Your Free Software? Use Power Point Tools If You Like!Include The Sketch It Below!

Page 70: MySQL Query Lab III 25 Points

70

Table Users Has 2 Fields & 21 Records

Page 71: MySQL Query Lab III 25 Points

71

SIMPLE JOIN

FROM Tab1, Tab2

Page 72: MySQL Query Lab III 25 Points

72

1] Display the Join Of Users & Team Members. Display Page 1 Do This Query On Your System!

Note That The Display Has 10 Fields (8 For Users & 2 For TeamMembers)

Note That The First Team Member Record (UserID = 6, TeamID = 1) Has Been Appended To Each & Every One Of The 15 User Records.

Note That The Second Team Member Record (UserID = 2, TeamID = 1) Has Been Appended To Each & Every One Of The 15 User Records.

Page 73: MySQL Query Lab III 25 Points

73

1] Display the Join Of Users & Team Members. Display Page 2

Note That The First Team Member Record (UserID = 15, TeamID = 1) Has Been Appended To Each & Every One Of The 15 User Records.

Note That The Second Team Member Record (UserID = 3, TeamID = 2) Has Been Appended To Each & Every One Of The 15 User Records.

Page 74: MySQL Query Lab III 25 Points

74

1] Display the Join Of Users & Team Members. Display Page 3

Note That The First Team Member Record (UserID = 11, TeamID = 2) Has Been Appended To Each & Every One Of The 15 User Records.

Note That The Second Team Member Record (UserID = 15, TeamID = 2) Has Been Appended To Each & Every One Of The 15 User Records.

Page 75: MySQL Query Lab III 25 Points

75

1] Display the Join Of Users & Team Members. Display Page 4

Note That The First Team Member Record (UserID = 4, TeamID = 3) Has Been Appended To Each & Every One Of The 15 User Records.

Note That The Second Team Member Record (UserID = 13, TeamID = 3) Has Been Appended To Each & Every One Of The 15 User Records.

Page 76: MySQL Query Lab III 25 Points

76

1] Display the Join Of Users & Team Members. Display Page 5

Note That The First Team Member Record (UserID = 15, TeamID = 3) Has Been Appended To Each & Every One Of The 15 User Records.

Note That The Second Team Member Record (UserID = 10, TeamID = 4) Has Been Appended To Each & Every One Of The 15 User Records.

Page 77: MySQL Query Lab III 25 Points

77

1] Display the Join Of Users & Team Members. Display Page 6

Note That The First Team Member Record (UserID = 14, TeamID = 4) Has Been Appended To Each & Every One Of The 15 User Records.

Note That The Second Team Member Record (UserID = 15, TeamID = 4) Has Been Appended To Each & Every One Of The 15 User Records.

Page 78: MySQL Query Lab III 25 Points

78

1] Display the Join Of Users & Team Members. Display Page 7

Note That The First Team Member Record (UserID = 8, TeamID = 5) Has Been Appended To Each & Every One Of The 15 User Records.

Note That The Second Team Member Record (UserID = 12, TeamID = 5) Has Been Appended To Each & Every One Of The 15 User Records.

Page 79: MySQL Query Lab III 25 Points

79

1] Display the Join Of Users & Team Members. Display Page 8

Note That The First Team Member Record (UserID = 15, TeamID = 5) Has Been Appended To Each & Every One Of The 15 User Records.

Note That The Second Team Member Record (UserID = 5, TeamID = 6) Has Been Appended To Each & Every One Of The 15 User Records.

Page 80: MySQL Query Lab III 25 Points

80

1] Display the Join Of Users & Team Members. Display Page 9

Note That The First Team Member Record (UserID = 9, TeamID = 6) Has Been Appended To Each & Every One Of The 15 User Records.

Note That The Second Team Member Record (UserID = 15, TeamID = 6) Has Been Appended To Each & Every One Of The 15 User Records.

Page 81: MySQL Query Lab III 25 Points

81

1] Display the Join Of Users & Team Members. Display Page 10

Note That The First Team Member Record (UserID = 1, TeamID = 7) Has Been Appended To Each & Every One Of The 15 User Records.

Note That The Second Team Member Record (UserID = 7, TeamID = 7) Has Been Appended To Each & Every One Of The 15 User Records.

Page 82: MySQL Query Lab III 25 Points

82

1] Display the Join Of Users & Team Members. Display Page 11

Note That The First Team Member Record (UserID = 15, TeamID = 7) Has Been Appended To Each & Every One Of The 15 User Records.

Table B = TeamMembers (21 Rows-Records)Table A = Users (15 Records)

Join Users, TeamMembers (21 x 15 = 315 Records)

Table B = TeamMembers (2 Fields)Table A = Users (8 Fields)

Join Users, TeamMembers (8 + 2 Fields)

In Reality, This Join As-Is, Is Pretty Worthless!

Page 83: MySQL Query Lab III 25 Points

83

Extracting Relationship Data!The Join Makes Sense When We Include The

Relationship In The Query!Replace The Screen Capture Below With Yours!

Page 84: MySQL Query Lab III 25 Points

84

SELECT …

Fully Qualified Field Names

Page 85: MySQL Query Lab III 25 Points

85

Fully Qualified Fields Descriptions Include Both The Table Name & The Field Name (Separated By A Period)

Note that the U.ID = T.UserID!We Often Want To Use ‘AS’ To Create More Meaningful Discriptors In

The Title Line Of Our Queries

Page 86: MySQL Query Lab III 25 Points

86

We Generally Restrict The Use Of Fully Qualified Fields To Those Times That They Are Absolutely Necessary!

Fully Qualified Names Are Necessary Only When Two Tables, Involved In A Join, Have The Exactly The Same Field Name!

Several Of Our Tables Have A Field Name Of ‘ID’. If A Query Joins Two Such Tables, It Is Necessary To Fully Qualify Which ID You Wish To Be Involved In The Query – It Is Not Necessary To Fully Qualify The Other Unique Field Names In

That Same Query!

Page 87: MySQL Query Lab III 25 Points

87

Questions #8 – Use Red Ink For Your Answers

33] __________ {T/F} We should always use fully qualified Field Names in all queries.

34] Write a Fully-Qualified Query that will display the ID, Name, and Phone of all Clients.SELECTFROM

34] __________ {T/F} We will normally use fully qualified Field Names in all queries that involve a join.

35] In your own words, tell when it is necessary to use fully qualified field names._________________________________________________________________________

_________________________________________________________________________

_________________________________________________________________________

Page 88: MySQL Query Lab III 25 Points

88

MySQL

IMPLEMENTING COMPLEX/LONG

QUERIES

Page 89: MySQL Query Lab III 25 Points

89

Helpful Hint (Slide 1)I Am Guessing That Some Of You May Have Made A Mistake Typing In

The Previous Query! (I Did!) . Complex/Long Queries Are Often Difficult To Get Exactly Right The First Time.

1] I Suggest You Enter The Query Into Notepad (or some other text editor). Copy It To The Clipboard (ctrl-c)

Page 90: MySQL Query Lab III 25 Points

90

Helpful Hint (Slide 2)

2] Right Mouse Click Any Where In Your Command Window Select Paste

Page 91: MySQL Query Lab III 25 Points

91

Helpful Hint (Slide 3)

3] If It Works Great! If Not, Modify The Notepad Text And Try Again! (This Is Much Less Stressful Than Trying To Correct It Inside The MySQL Environment)

Page 92: MySQL Query Lab III 25 Points

92

SELECT …

Fully Qualified Field Names

(Continued)

Page 93: MySQL Query Lab III 25 Points

93

1] Display The ID, FullName, UserName, And TeamID For All Users (Fully Qualified Fields)

Replace The Capture Below With Yours!

Whenever I Provide You With A Capture Of The Query Table Titles (such as the one below), You Are To Match Those Titles (EXACTLY i.e. U-FullName, etc.) In Your Capture!

Page 94: MySQL Query Lab III 25 Points

94

Database Development

Walk Through Some Of The Thought Process

Page 95: MySQL Query Lab III 25 Points

95

Start Of A Simple Application

Computer Science Library Where Dr. Hicks

Server Teams Can Check Out Books

Page 96: MySQL Query Lab III 25 Points

96

Database Development

We Have Some UsersEntity

Page 97: MySQL Query Lab III 25 Points

97

There Are Lots Of Programs That Help Support & Automate Design To Implementation

This Is Not The Most Expensive – Look For These Tools If You Are Doing This For A Living!

Page 98: MySQL Query Lab III 25 Points

98

------------- Systems Analysis Phase -------------

At First People Used E-R Diagrams(And Some Still Do)

ID

First

Last

Phone

Email

Administrator

UserName

FullName

Users

Page 99: MySQL Query Lab III 25 Points

99

------------- Systems Analysis Phase -------------There Are Some Software Packages That Will Prompt You For Data-Typing As You Create The Entities In The E-R Diagram& Generate A Database Table (Expensive & Database Specific)

ID

FirstLast

Phone

Email

AdministratorUserName

FullName

Users

Page 100: MySQL Query Lab III 25 Points

100

------------- Systems Analysis Phase -------------E-R Get Clutsey When We Have 30-80 Fields ??

You Often Have To Turn Around And Enter Redundant Info Into The Database!

-- Effort & Time Intensive --

ID

First

Last

Phone

Email

Administrator

UserName

FullName

Users

Page 101: MySQL Query Lab III 25 Points

101

------------- Systems Analysis Phase -------------There Are Many GUI’s That Make Design & Re-Design

Much Easier & Faster Than Corresponding SQL.

Page 102: MySQL Query Lab III 25 Points

102

------------- Systems Analysis Phase -------------A Lot Of Users Are Creating The Table During The Design StageKnowing That There Will Often Be Changes & Revisions

These can Be Done Easily With The GUI - And GUI’s Often Have View!

In One Click We Can Generate The Users Table In A View!

Page 103: MySQL Query Lab III 25 Points

103

Navicat

I Have A License For Your Server – But Not

For Your Personal Computer

Page 104: MySQL Query Lab III 25 Points

104

Google Search: Navicat (Include Databses SupportedVersions & Pricing)Replace The Screen Capture Below With Yours!

Page 105: MySQL Query Lab III 25 Points

105

NAVICAT CONFIGURATION

&Basics

Page 106: MySQL Query Lab III 25 Points

106

Google Search: Navicat (Include Databses SupportedVersions & Pricing)Replace The Screen Capture Below With Yours!

Page 107: MySQL Query Lab III 25 Points

107

Start Navicat (Yours May Be Some Different)Install Navicat On Your Home System If You Desire

Replace The Screen Capture Below With Yours!

File -> New Connection

Page 108: MySQL Query Lab III 25 Points

108

Create A Navicat Connection & Test Replace The Screen Capture Below With Yours!

Page 109: MySQL Query Lab III 25 Points

109

The Navicat InterfaceReplace The Screen Capture Below With Yours!

Page 110: MySQL Query Lab III 25 Points

110

To Open The Table Designer For Users Right-Mouse Click On Users Select Design

Page 111: MySQL Query Lab III 25 Points

111

The Navicat Table Design InterfaceReplace The Screen Capture Below With Yours!

Page 112: MySQL Query Lab III 25 Points

112

To Open Graphical Table Interface For Users Double Click On Users

Page 113: MySQL Query Lab III 25 Points

113

To A New View For The Library?? Database Click On View (Connections Panel Left) Push New View (Right)

Page 114: MySQL Query Lab III 25 Points

114

Select The View Builder TabUsing The Mouse, Drag The Users Table To The View

Page 115: MySQL Query Lab III 25 Points

115

UsersA User Can Be A Member Of One, Two, Or More Server Teams.

User Tom Hicks Is Going Is An “Access-Only” Member Of All Server Teams.

Page 116: MySQL Query Lab III 25 Points

116

My Table Users Has 8 Fields & 15 RecordsInclude The Sketch It Below!

Page 117: MySQL Query Lab III 25 Points

117

1] Display The Number Of Users2] Display The Number Of Users That Have An ‘H’ As The First Two Letters In The LastName 3] Display The Number Of Users Whose First Name Is ‘Tom’ Include The Capture Below!

Page 118: MySQL Query Lab III 25 Points

118

1] Display All Of The First, Last, And E-Mail In UpperCase In Ascending Alphabetical Order By E-Mail

Include The Capture Below!

Page 119: MySQL Query Lab III 25 Points

119

1] Display All Of The First, Last, Username, And E-Mail In LowerCase In Descending Alphabetical Order By FullName

Include The Capture Below!

Page 120: MySQL Query Lab III 25 Points

120

ServersA Single Server Will Have One Team Assigned To It!

Table Servers Has All Of The Server Network Configuration Information.

Page 121: MySQL Query Lab III 25 Points

121

My Table Servers Has 7 Fields & 7 RecordsInclude The Sketch It Below!

Page 122: MySQL Query Lab III 25 Points

122

1] Display The Number Of Servers 2] Display The Number Of Servers That Have A ‘CS’ As The First Two Letters In The ServerName 3] Display The Number Of Servers Whose TeamName Starts With ‘S’ Include The Capture Below!

Page 123: MySQL Query Lab III 25 Points

123

1] Display The ID, TeamName, and ServerName Of Servers 2] Display The ID, StaticIP, SubnetMask, and Gateway Of All Servers

Include The Capture Below!

Page 124: MySQL Query Lab III 25 Points

124

1] Display The ID, StaticIP, SubnetMask, and Gateway Of All Servers Whose TeamName Starts With An ‘S’

Include The Capture Below!

Page 125: MySQL Query Lab III 25 Points

125

1] Display All Of The Team Name In UpperCase In Ascending Alphabetical Order.

Include The Capture Below!

Page 126: MySQL Query Lab III 25 Points

126

1] Display All Of The Team Name In LowerrCase In Descending Alphabetical Order.

Include The Capture Below!

Page 127: MySQL Query Lab III 25 Points

127

TeamsTeams Is A Relationship Between Users and Servers.

Some Folks Would Prefer That We Name This Table “Administers”: John Administers Server CS-1.

I Am Trying To Emphasize Our Server Teams.

Page 128: MySQL Query Lab III 25 Points

128

My Table Teams Has 2 Fields & 21 RecordsReplace The Sketch It Below!

Page 129: MySQL Query Lab III 25 Points

129

Relationship

Page 130: MySQL Query Lab III 25 Points

130

Change Your Window Layout To Match That Below! Replace The Capture Below!

Page 131: MySQL Query Lab III 25 Points

131

Execute Query SELECT *FROM Users, Teams, Servers

The Sketch Below Shows Part Of The Query Title Line. Screen Capture The Rest Of The Query Title Line & Include It Below. Use Multiple

Captures If Necessary To Make It Readable.

Join Users, Teams, ServersTable Users Has ____ FieldsTable Teams Has ____ FieldsTable Servers Has ____ FieldsQuery Has ____ Fields/Columns

Page 132: MySQL Query Lab III 25 Points

132

Continue With Query SELECT *FROM Users, Teams, Servers

Replace The Sketch Below With One From The Bottom Of Your Query That Shows The Number Of Rows.

Join Users, Teams, ServersTable Users Has ____ RecordsTable Teams Has ____ RecordsTable Servers Has ____ Records Query Has ____ Records/Rows

Page 133: MySQL Query Lab III 25 Points

133

Change Your Window Layout To Match That Below! Replace The Capture Below!

Page 134: MySQL Query Lab III 25 Points

134

Display The First, Last, TeamName, And ServerName for Everybody!A Meaningful Query

Replace The Capture Below!

It would be much more efficient to use an Inner Join; we will get to that later.

Page 135: MySQL Query Lab III 25 Points

135

CHANGETHE

DATA

Page 136: MySQL Query Lab III 25 Points

136

Reload The Library-Hicks-2.sql

Page 137: MySQL Query Lab III 25 Points

137

Do You Understand

Page 138: MySQL Query Lab III 25 Points

138

Once Again We Want To Execute Query SELECT *

FROM Users, Teams, Servers

But The Data Has Changed. Don't Do It Yet!

Join Users, Teams, ServersTable Users Now Has ____ FieldsTable Teams Now Has ____ FieldsTable Servers Now Has ____ Fields

I Am Guessing That The Query Will Have ____ Fields

Page 139: MySQL Query Lab III 25 Points

139

Once Again We Want To Execute Query SELECT *

FROM Users, Teams, Servers

But The Data Has Changed. Don't Do It Yet!

Join Users, Teams, ServersTable Users Now Has ____ RecordsTable Teams Now Has ____ RecordsTable Servers Now Has ____ Records

I Am Guessing That The Query Will Have ____ Records

Page 140: MySQL Query Lab III 25 Points

140

Once Again We Want To Execute Query SELECT *

FROM Users, Teams, Servers

Do The Query Now!

Join Users, Teams, Servers

The Query Has ____ FieldsThe Query Has ____ Records

_______ My Guesses {were/were not} correct

Page 141: MySQL Query Lab III 25 Points

141

1] Display The First, Last, E-Mail, Phone, ServerName, and URL Users Whose ID <= 5 In Order By FullName

Include The Capture Below!

Page 142: MySQL Query Lab III 25 Points

142

1] Display The Servers.ID, ServerName, TeamName, First, and Last Of All Systems In Order By TeamName.

Include The Capture Below!

Page 143: MySQL Query Lab III 25 Points

143

1] Display “No People On The Team Whose ServerID = 4 Is ???” Use Count(*)

Include The Capture Below!

Page 144: MySQL Query Lab III 25 Points

144

Database Generally

ImpliesRelationships

Page 145: MySQL Query Lab III 25 Points

145

How Are The Library Tables RelatedReplace The View Below With Yours!

Page 146: MySQL Query Lab III 25 Points

146

1] List the following information about all the authors that start with an HYour query is top generate exactly the same output as mine. Don't Delete My Output!BA is BookAuthors - OrdrBy A.Name

Include The Capture Below - Include Query and Output In Capture

It Looks Like Hector May Have Authored Two Books?

Page 147: MySQL Query Lab III 25 Points

147

1] List the following information about all the authors that start with an HYour query is top generate exactly the same output as mine. List 25 characters of the Title. Don't Delete My Output! OrdrBy A.Name

Include The Capture Below - Include Query and Output In Capture Hector

Authored Two Books?

Page 148: MySQL Query Lab III 25 Points

148

1] List the following information about books written by Joel MurachYour query is top generate exactly the same output as mine. List 25 characters of the Title. Don't Delete My Output!

Include The Capture Below - Include Query and Output In Capture

Page 149: MySQL Query Lab III 25 Points

149

1] List the following information about all of the authors of book ID = 23 Your query is top generate exactly the same output as mine. List 25 characters of the Title. Don't Delete My Output! - OrdrBy A.Name

Include The Capture Below - Include Query and Output In Capture

Page 150: MySQL Query Lab III 25 Points

150

1] List the following information about all of the authors of book ID = 23 Your query is top generate exactly the same output as mine. List 25 characters of the Title. Don't Delete My Output! - OrdrBy A.Name

Include The Capture Below - Include Query and Output In Capture

Page 151: MySQL Query Lab III 25 Points

151

1]Harvey's name has a leading blank. Perhaps there are others. Create a query that will get rid of leading and trailing blanks in all Author records.

Include The Capture Below - Include Query and Output In Capture