
































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

































1. What is a Database?
● Definition: A database is an organized collection of data and a method to easily manipulate and access that data. ● Real-life Example: Imagine trying to find a specific Science book in a massive room full of randomly dumped books. It would be a nightmare! But if those books are organized by subject and alphabetical order (like in a library), finding your book is quick and easy. A database does this for digital data. ● Structure: Data is usually stored in an organized format, like rows and columns (e.g., storing a person's First Name, Last Name, City, and Contact Number).
2. Why use a Database instead of MS Excel?
● While Excel is great for small amounts of data, it struggles with millions of records. ● If you have a massive dataset, Excel loses its efficiency—files take forever to load, searching becomes incredibly slow, and the file might even crash or refuse to open. Databases are built specifically to handle massive amounts of data efficiently.
3. Database vs. DBMS
● Database: The actual place where the data is stored. ● DBMS Database Management System): The software that acts as a bridge between your application (like a mobile app or website) and the database. ● How it works: When you enter information into an app, the DBMS takes that data, processes it, and securely organizes it into the database. Examples of DBMS include PostgreSQL, MySQL, and Oracle.
4. What is RDBMS?
● RDBMS stands for Relational Database Management System. ● It is a specific type of DBMS where data is stored in structured tables consisting of rows and columns.
● The word "Relational" means the data is organized in a tabular format and different tables can be linked (related) to each other.
5. Popular Databases in the Market
● Besides PostgreSQL, there are many other databases used for different purposes: MySQL, Oracle, MongoDB (a popular non-relational database), Redis, and MariaDB. ● Why learn PostgreSQL? It is currently one of the most advanced, open-source, and highly-in-demand databases in the tech industry.
6. SQL vs. PostgreSQL
● PostgreSQL This is the actual software tool (the RDBMS that stores and manages your data. ● SQL Structured Query Language): This is the language you use to talk to the database. ● Analogy: If PostgreSQL is the person you are giving instructions to, SQL is the language (like English or Hindi) you use to give those instructions. For example, SELECT * FROM table_name is a SQL command used to ask PostgreSQL to show you data.
● The Database (Instagram_DB): ○ Represents the entire application’s data storage. ● The Schemas (Logical Grouping): ○ Instead of dumping hundreds of tables into one messy pile, you divide the database into functional groups (schemas): ■ user_schema: Holds everything strictly related to users (profiles, followers, account settings). ■ media_schema (or public): Holds everything related to content (posts, videos, reels). ● The Tables (Specific Datasets inside a Schema): ○ Inside the media_schema, you have separate tables: ■ posts table ■ reels table ○ Inside the user_schema, you have separate tables: ■ user_profiles table ■ followers table
3. Summary Comparison Table
Term What is it? Purpose Example
Database The main container
Houses all application data and settings
instagram_db, bank_db
Schema A namespace / folder
Groups related tables to avoid clutter and naming conflicts
public, user_data, billing
Table The collection of data rows
Stores actual records in structured columns and rows
users, reels, orders
This section covers fundamental database administration tasks: how to view, create, switch between, and delete databases using both the psql command line (CLI) and the pgAdmin 4 GUI.
ask CLI Shortcut / Command
SQL Query GUI (pgAdmin) Action
List Databases
\l SELECT datname FROM pg_database;
View under Databases tree
Create Database
db_name;
Right-click Databases $\rightarrow$ Create
Switch Database
\c db_name — Select DB $\rightarrow$ Open Query Tool
Delete Database
db_name;
Right-click DB $\rightarrow$ Delete/Drop
○ Example: If a bank app requires an account type but the user leaves it blank, you can set the constraint as DEFAULT 'Savings' so it automatically assigns "Savings". ● SERIAL Auto-Increment): Instead of manually keeping track of IDs 101, 102, 103...), PostgreSQL uses the SERIAL data type. It automatically generates and increases the ID number by 1 every time a new row is added.