# Database and Database Management System

### **What is a Database?**

Imagine you have a **library**. In this library, all the books are organized and stored in an orderly fashion. Each book has a title, an author, a genre, and so on. Now, to easily find a book, you need some sort of catalog that helps you search by title, author, genre, etc. This **catalog** is like a **database,** a collection of organized information that can be easily accessed, managed, and updated.

In the digital world, instead of books, databases store all kinds of information: from customer details, product inventories, or even social media posts! A **database** is simply a way to store this information in a structured and organized manner so that you can retrieve it easily when needed.

### **What is a DBMS?**

Now, imagine that your library has a **librarian**. The librarian’s job is to maintain the library, keep track of the books, check out books to readers, and make sure the books are returned on time. In the world of computers, this librarian is like a **DBMS** (Database Management System).

A **DBMS** is software that helps manage and control how data is stored, accessed, and updated in a database. It allows people and applications to interact with the database without worrying about how the data is physically stored on disk. Just like the librarian ensures everything is in order, the DBMS ensures that the data is organized, safe, and easy to retrieve.

### **Types of Database Models**

Just like there are different ways to organize a library (such as by genre, author, or alphabetically), there are different **models** for organizing and managing data in a database. Let’s take a look at a few common database models and use simple analogies to explain each.

#### a. Hierarchical Database Model

Now, imagine you organize the library in a **family tree-like structure**. Books are organized by **categories**. For example, you could have a main category called **"Fiction"**, and underneath that, you have sub-categories like **"Science Fiction"** and **"Historical Fiction"**. Each of these sub-categories can have books listed under them.

The **hierarchical model** works like this data is organized in a **tree-like structure** with one parent category leading to multiple child categories.

or example, in a book catalog:

* Fiction
  * Science Fiction
    * "Dune"
    * "The Martian"
  * Historical Fiction
    * "The Book Thief"
    * "War and Peace"

This structure is easy to understand, but it’s rigid. What if a book fits into more than one category? For instance, if "Dune" is both **Science Fiction** and **Adventure**, the hierarchical model makes it difficult to store this book in both categories without duplication.

#### **b. Network Database Model**

The **network model** is like a **web** of relationships between data. Instead of organizing data strictly into a parent-child structure, this model allows data to be linked in more complex ways. Imagine if, in the library, books could belong to multiple categories at once, and the categories themselves could have cross-links.

For example:

* A book like **"The Martian"** could be part of both **Science Fiction** and **Adventure** categories.
* The **Adventure** category might link to **Historical Fiction** because some historical books can also be adventurous.

In this model, data points are linked in a more flexible, interconnected way, like a **web of relationships**. This allows for more complex data storage but can also get confusing to manage as the web grows.

#### **c. Relational Database Model**

The **relational model** is like the **best-organized library**. Imagine every book in the library is in a separate shelf, and each shelf is labeled. Instead of just having one big list or tree, you organize the books into separate categories based on different criteria, like **books**, **authors**, **genres**, and **borrowers**. These separate categories are like **tables**, and you can link them together through **relationships**.

For example:

* A **Books Table** lists all the books.
* An **Authors Table** lists the authors.
* A **Genres Table** lists all genres.

Each table has a unique **identifier** (like a library card number) to connect the pieces of information. If you want to know which books an author has written, you can look up that author’s unique ID and see which books are related.

This model is **flexible** and allows you to store vast amounts of data with **relationships** between them. You can easily query the database, like asking the librarian for all books in the "Science Fiction" genre or by a specific author.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://courses.parottasalna.com/database-engineering/database-and-database-management-system.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
