Server-Side Scripting/Document Databases
This lesson introduces document database processing.
utiuu
Objectives and Skills
editObjectives and skills for this lesson include:
- Understand NoSQL database concepts
- Understand document database concepts
- Use a document database with server-side scripts
Readings
editMultimedia
editTutorials
editBefore trying to work with any database using a programming language, you should first be familiar with that database's command language. The following tutorials will be helpful in understanding how to use MongoDB.
Examples
editThe following examples use MongoDB as the document database. A similar approach would work for almost any document-based database.
Activities
editComplete the following activities using HTML, CSS, and a server-side scripting language. Apply best practices for user interface design and your selected scripting language, including modules, comments, indentations, naming conventions, and constants. Use HTML forms and input elements for input, server-side scripts for processing, and HTML elements for output. Use separate functions for each type of processing. Avoid global variables by passing parameters and returning results. Add comments at the top of the code modules and include references to any resources used. Add the completed code to your website as /lesson10
.
- Create an application that allows the user to insert, update, and delete records in a document database. After each action, display the current records. Use any document database and data structure you like. Be sure to include date, text, and number field types in the data structure. If in doubt, any of the previous cyclone, earthquake, or wildfire activities may be used as data examples.
Lesson Summary
editAdditional items may be contributed by course participants
- NoSQL databases are non tabular, and store data differently than relational tables. NoSQL databases come in a variety of types based on their data model. The main types are document, key-value, wide-column, and graph. They provide flexible schemas and scale easily with large amounts of data and high user loads.[1]
- NoSQL databases are sometimes viewed as more flexible than relational databases. [2]
- Significant terminology and usage differences between a document database and a relational database are important to understand. In a document database, a Document is similar to a Record containing a set of information for a particular item. Documents can each have a unique structure where Records in a relational database all have the same format. Documents are store in a Collection that is similar to a Table in a relational database.[3]
- MongoDB is a document database that stores data in JSON-like documents. It supports arrays and nested objects as values.[4]
- MongoDB requires and automatically adds a unique identifier field called _id to each document in the collection.[5]
- MongoDB stores data records as documents (specifically BSON documents) which are gathered together in collections. A database stores one or more collections of documents.[6]
- The $set operator replaces the value of a field with the specified value.[7]
- Indexes can be added to MongoDB collections. Without them when queries are preformed MongoDB searches every document, but indexing can limit searches to relevant documents in some cases. [8]
Key Terms
editAdditional items may be contributed by course participants
- collection
- Equivalent to a table in relational databases.[9]
- document (BSON)
- A data structure composed of field and value pairs.[10]
See Also
editReferences
edit- ↑ https://www.mongodb.com/nosql-explained
- ↑ "NoSQL". Wikipedia. 2021-03-17. https://en.wikipedia.org/w/index.php?title=NoSQL&oldid=1012591958.
- ↑ Guru99: What is MongoDB? Introduction, Architecture, Features & Example
- ↑ https://www.mongodb.com/
- ↑ Guru99: Key Components of MongoDB Architecture
- ↑ https://docs.mongodb.com/manual/core/databases-and-collections/
- ↑ MONGODB MANUAL
- ↑ "Indexes — MongoDB Manual". GitHub.com. Retrieved 2021-04-02.
- ↑ https://docs.mongodb.com/manual/introduction/
- ↑ https://docs.mongodb.com/manual/introduction/#document-database