# Database software installation

## Database and DBMS

Until now we stored our data inside classes. *Databases* allow a more organized way of managing data.

:::{wpd} database
an organized collection of data
:::

For example, a table called `Items` look like:

:::{list-table}
:header-rows: 1
* - Name
  - PricePerUnit
  - InventoryLocation
* - M3 screw
  - 1.0
  - 1
* - M3 nut
  - 1.5
  - 2
* - pen
  - 1.0
  - 3
:::

Database management system (DBMS)
: software that interacts with user and the database

There are many DBMSs. We will use SQLite.

## Installation SQLite

::::{tab-set}
:::{tab-item} {{apple}} MacOS
```sh
brew install sqlite
```
:::
:::{tab-item} {{windows}} Windows
```sh
winget install sqlite.sqlite
```
:::
::::
<!--
brew install --cask db-browser-for-sqlite
 dbbrowserforsqlite.dbbrowserforsqlite
-->

## OOP-based database interaction

There are many ways to read write data to a database. We will use an OOP-based approach. Microsoft provides a library called `Entity Framework Core` (EF) which we will use.

Using EF, we can map the hierarchy of our classes to a database.

## Installation of `Entity Framework Core`

Install the following NuGet packages on Rider:

1. `Microsoft.EntityFrameworkCore`
1. `Microsoft.EntityFrameworkCore.Sqlite`

Using the first package we can read/store data using objects we created using OOP. The second one is required to work with the database software SQLite.

