Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Science Department

Similar presentations


Presentation on theme: "Computer Science Department"— Presentation transcript:

1 Computer Science Department
Mongo Database Database Systems CSCI-3343 Dr. Tom Hicks Computer Science Department

2 Use Military Sets The Default Database  Does Not Create Until Data Added Sets db

3 Create Table officer  Add Tom
db.officer.insert({name: "Tom"})

4 db.officer.insert({name: "Tom"}) db.officer.insert({name: "Dick"})
db.officer.insert({name: "Harry"}) db.officer.insert({name: "Sally"}) db.officer.insert({name: "Judy"}) db.officer.insert({name: "Ann"}) db.officer.insert({name: "Craig"}) db.officer.insert({name: "Betty"}) C R E A TE T E X T F I L E save as C:\Temp\Officers.txt

5 Add officers  Dick, Harry, Sally, Judy, Ann, Craig, & Betty

6 Show Database Tables  Collections
show collections

7 Show Records In Officer Collection
db.officer.find() We Will Not Have The Same _id

8 Show Records In Officer Collection

9 Show Officer Records In Order By Name
db.officer.find().sort({name:1})

10 Show Officer Name db.officer.find({}, {name:1, _id:0})

11 What Would You Expect From Query
db.officer.find({}, {name: 1, _id: 1})

12 Delete The Officer collection
db.officer.drop()

13 Put The Add officer Queries In A Text File  Save As C:\Temp\Officers
Put The Add officer Queries In A Text File  Save As C:\Temp\Officers.txt

14 Put The Add officer Queries In A Text File  Save As C:\Temp\Officers
Put The Add officer Queries In A Text File  Save As C:\Temp\Officers.txt

15 Show 4 Officer Records db.officer.find().limit(4)

16 hostInfo db.hostInfo()

17 Create Table plane  Add F-16
db.plane.insert({Category: "F-16 Fighting Falcon"})

18 Show Databases show dbs

19 Show Database Tables  Collections
show collections

20 Show Records In Plane Collection
db.plane.find()

21 Create Table consultant  Add Miguel
db.consultant.insert({name: "Miguel", rank: "Major"})

22 What Conclusions Might You Draw From The Following?
Collection Names Are Case Sensitive

23 Delete The plane & Officer collections
db.plane.drop() db.Officer.drop()  do not drop officer!

24 Delete officer Harry db.officer.remove({name: "Harry"})

25 Create 3 planes  Add F16, F-22A, F-35A
db.plane.insert({category: "F-16 Fighting Falcon"}) db.plane.insert({category: "F-22A Raptor"}) db.plane.insert({category: "F-35A Lightning II"})

26 Delete All Of The planes
db.plane.remove()

27 What Can You Conclude From The Following?
Data Strings are Case Sensitive

28 db.consultant.insert({name: "Miguel", rank: "Major"})
db.consultant.insert({name: "Colby", rank: "Captain"}) db.consultant.insert({name: "Jeff", rank: "Lieutenant"}) db.consultant.insert({name: "Charlie", rank: "Colonel"}) db.consultant.insert({name: "Po", rank: "Colonel"}) db.consultant.insert({name: "Charlie", rank: "Major"}) db.consultant.insert({name: "Stephen", rank: "Captain"}) C R E A TE T E X T F I L E

29 Can You Past Records Into Mongo Command Line?
Depends upon OS  Getting A Little Tired Of Command Line! Save File  C:\Temp\Consultants.txt

30 Robomongo - Freeware/Donations

31 Install Robomongo 1

32 Install Robomongo 2

33 Install Robomongo 3

34 Show Military Officer Records

35 Connect Robomongo 1

36 RM  Paste Queries - RUN

37 RM Show The consultant Collection

38 RM  Close The Query Window
How Can You Get The Query Tab Back?

39 RM  Show All Of The Information About consultant 'Miguel'

40 What Conclusion Could You Draw From The Following?
We can delimit strings with either ' or "

41 RM  Show All Of The Information About consultant 'Captain'

42 Show _id & rank For All consultants
db.consultant.find({}, {rank:1})

43 Show _id & name For All consultants
db.consultant.find({}, {name:1})

44 Show name For All consultants
db.consultant.find({}, {name:1, _id:0})

45 Show name & rank For All consultants  By name
db.consultant.find({}, {name:1, _id:0, rank:1}).sort({name:1})

46 Show name & rank For All consultants  By rank
db.consultant.find({}, {name:1, _id:0, rank:1}).sort({rank:1})

47 Show name & rank For All consultants  By rank By name
db.consultant.find({}, {name:1, _id:0, rank:1}).sort({rank:1, name:1})

48 We Have One Too Many Charlie's  Delete The Second One
If you make a mistake, drop the table and re-fill it from the file

49 Any Of You Try ? #1 db.consultant.remove ({name: "Charlie"})
If So: drop consultant & reload from file

50 Any Of You Try ? #2 db.consultant.remove ({name: "Charlie"}) xxx
db.consultant.remove({ _id: "582db96d266770a208a5adfb"})

51 Any Of You Try ? db.consultant.remove ({name: "Charlie"}) xxx
db.consultant.remove({ _id: "582db96d266770a208a5adfb"}) xxx db.consultant.remove({name: "Charlie", rank: "Major"})

52 What Can You Conclude? Field Names Are Case Sensitive

53 What Can You Conclude? I can choose to delimit the field names with " or '  or not!

54 Pretty db.consultant.find({rank: "Captain"}).pretty()

55 RM  List All Of The Info About Colonels  pretty
Disappointed?

56 RM  Default View  allows you to expand

57 RM  Spreadsheet View

58 RM  Jason View

59 Show name & rank For All consultants  By rank By name  First 4
db.consultant.find({}, {name:1, _id:0, rank:1}).sort({rank:1, name:1}).limit(4)

60 stats()


Download ppt "Computer Science Department"

Similar presentations


Ads by Google