Exercise 1

Insert (Insert_one, Insert_many), Update, Delete

  • Use a ex1 database and imdb collection.

  • We are going to make a movie database like IMDb.

  • Each movie has following information.

    • title: String

    • director: String

    • genre: List(String)

    • score: Double

  • Insert a movie

    • Write a script that inserts movie information to a movie collection.

    • Type the movie information as follows:

    • Movie Title: Avengers: Infinity War

      Director: Anthony Russo and Joe Russo

      Genre: Action, Adventure, Drama

      score: 8.6

      [INFO] Success to insert!

    • Plain: Terminal output

    • Bold: User input

    • Hint: use a input() function

  • Confirm that the insertion is operated properly.

  • Print only movie’s title(s)

  • Insert three movies more. Use insert_many

    • Movie Title: Bohemian Rhapsody

      Director: Bryan Singer

      Genre: Biography, Drama, Music

      score: 8.1

      Quit (Y/n)? n

    • Movie Title: Happy Death Day 2U

      Director: Christopher Landon

      Genre: Drama, Horror, Mystery

      score: 6.6

      Quit (Y/n)? n

    • Movie Title: Spider-Man: Into the Spider-Verse

      Director: Bob Persichetti, Peter Ramsey

      Genre: Animation, Action, Adventure

      score: 8.6

      Quit (Y/n)? Y

      [INFO] Success to insert!

  • Confirm that the insertion is operated properly.

  • Print only movie’s title(s)

  • Update movie information

    • Querying movie title and update the information

    • [INFO] Enter the information which you want to edit

      Movie Title: Avengers: Infinity War

      Director: Anthony Russo and Joe Russo

      Genre: Action, Adventure, Drama

      score: 8.6

      [INFO] Success to update!

    • Plain: Terminal output

    • Bold: query

    • Italic: update

  • Print all documents

  • Remove movie (Plain: Output, Bold: User input)

  • Remove a document

    • [INFO] Enter the title which you want to remove

      Movie Title: Happy Death Day 2U

      [INFO] Are you sure? (Y/n) Y

      [INFO] Deleted

  • Result

Last updated

Was this helpful?