Learn RDBMS, NoSQL, SQL vs NoSQL & Database Design
Learn the fundamentals of databases in this beginner-friendly guide. Understand relational vs non-relational databases, SQL vs NoSQL, database terminology (tables, rows, columns, schema, primary & foreign keys), database design basics, and practical tasks like installing MySQL, SQL Server, PostgreSQL, or Oracle and creating your first database and table.
1. What is a Database?
A database is a structured collection of data that allows you to store, manage, and retrieve information efficiently.
Key Points:
- Databases are essential for applications, websites, and data analytics.
- They ensure data integrity, consistency, and security.
- Databases can store structured, semi-structured, or unstructured data.
2. Types of Databases
2.1 Relational Databases (RDBMS)
- Data is stored in tables with rows and columns.
- Tables can have relationships through primary and foreign keys.
- Examples: MySQL, SQL Server, PostgreSQL, Oracle
Example Table: Employees
| IDNameDepartmentSalary | |||
| 1 | Alice | HR | 50000 |
| 2 | Bob | IT | 60000 |
2.2 Non-Relational Databases (NoSQL)
- Data can be document-based, key-value, graph, or columnar.
- Flexible schema; good for big data and real-time applications.
- Examples: MongoDB, CouchDB, Cassandra
3. SQL vs NoSQL
| FeatureSQL (Relational)NoSQL (Non-relational) | ||
| Schema | Fixed schema | Dynamic schema |
| Query Language | SQL | API/Query language varies |
| Scaling | Vertical scaling | Horizontal scaling |
| Use Case | Transactional apps, banking | Big data, analytics, real-time apps |
4. Database Terminology
| TermDescription | |
| Table | Collection of related data (rows & columns) |
| Row / Record | A single entry in a table |
| Column / Field | Attribute or data type in a table |
| Schema | Structure of the database (tables, columns, relationships) |
| Primary Key | Unique identifier for each row |
| Foreign Key | Links a row in one table to a row in another table |
5. Database Design Basics
- Plan tables based on entities and relationships.
- Normalize data to avoid redundancy.
- Identify primary and foreign keys to establish relationships.
- Use ER diagrams (Entity-Relationship diagrams) for visual design.
6. Practical Tasks
6.1 Install a Database Server
- MySQL: https://dev.mysql.com/downloads/
- SQL Server: https://www.microsoft.com/en-us/sql-server
- PostgreSQL: https://www.postgresql.org/download/
- Oracle Database: https://www.oracle.com/database/
6.2 Create Your First Database
6.3 Create Your First Table
6.4 Understand Schema and Relationships
- Each table has a schema defining its columns and data types.
- Relationships are defined using primary and foreign keys:
7. Practice Exercises
- Install a database server of your choice (MySQL / SQL Server / PostgreSQL / Oracle).
- Create a database called
CompanyDB. - Create a table
Employeeswith ID, Name, Department, Salary. - Create another table
Departmentswith DeptID, DeptName. - Establish a foreign key relationship between Employees and Departments.
- Insert sample data and explore the table structure.