Elaboración de las Bases de Datos GA6-220501096-AA1-EV04 a cargo del instructor Carlos Fuel.
Introduction to Database Creation
Overview of the Task
- John Alexander Ríos introduces himself and outlines the task of creating a database named "parqueadero" as instructed by Carlos Fuel. The process begins with establishing a new connection.
Steps to Create the Database
- The first step involves naming the connection "axo" along with his identification number, followed by saving and connecting.
- Next, he creates the database "parqueadero" and establishes a collection called "vehículo." This is done using an interface option to create a new database.
Inserting Documents into the Collection
Document Insertion Process
- John explains how to insert five documents into the "vehículo" collection, starting by creating a document labeled as "documento dos." He prepares data in a text file for this purpose.
- To add these documents, he uses specific code:
db vehículo.insertMany(), ensuring that all five entries are successfully added to the collection. The confirmation indicates that five records were inserted correctly.
Updating Records in the Database
Updating Existing Entries
- The next task is updating both the first and last records in the collection. For instance, he updates a record with plate number "TV 36G," changing its model from 2024 to 2025 using appropriate code syntax. This change is confirmed as successful.
- After updating, he lists all data again to verify that changes have been applied correctly; indeed, it shows that the model has been updated successfully from 2024 to 2025.
Further Updates and Deletions
Final Record Update
- John proceeds to update the last record's model from its previous value to 2040 while maintaining similar coding structure used for earlier updates; this action also confirms success upon execution.
Deleting Records
- He then demonstrates how to delete a specific document (the third one) from the collection using
db vehículo.deleteOne()command based on its ID, confirming successful deletion afterward by listing remaining records which now show only four entries instead of five.
Retrieving Specific Documents
Querying Data Based on Criteria
- Finally, John illustrates how to retrieve information about a specific vehicle based on its plate number using
db vehículo.findOne(). This query returns detailed information associated with that particular entry in the database effectively demonstrating targeted retrieval capabilities within MongoDB collections.
Conclusion
Wrap-Up
- John concludes his presentation expressing hope that viewers found it informative and thanking them for their attention throughout this tutorial on database management tasks involving creation, updating, deleting, and querying within MongoDB collections.