Server-Side Scripting/Document Databases

From Wikiversity
Jump to navigation Jump to search

This lesson introduces document database processing.


Objectives and Skills

[edit | edit source]

Objectives and skills for this lesson include:

  • Understand NoSQL database concepts
  • Understand document database concepts
  • Use a document database with server-side scripts


[edit | edit source]
  1. Wikipedia: NoSQL
  2. Wikipedia: Document-oriented database


[edit | edit source]


[edit | edit source]

Before 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.


[edit | edit source]

The following examples use MongoDB as the document database. A similar approach would work for almost any document-based database.


[edit | edit source]

Complete 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.

  1. 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

[edit | edit source]

Additional 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

[edit | edit source]

Additional items may be contributed by course participants

Equivalent to a table in relational databases.[9]
document (BSON)
A data structure composed of field and value pairs.[10]

See Also

[edit | edit source]


[edit | edit source]
  2. "NoSQL". Wikipedia. 2021-03-17. 
  3. Guru99: What is MongoDB? Introduction, Architecture, Features & Example
  5. Guru99: Key Components of MongoDB Architecture
  8. "Indexes — MongoDB Manual". Retrieved 2021-04-02.