Skip to main content

Course Progress

Loading...

Types of Databases

Duration: 45 minutes
Module 3: Session 1

🎯 What You'll Learn

  • Differences between relational and non-relational databases
  • When to use each type of database
  • Popular database systems and their uses
  • How WordPress uses relational databases
  • Basic understanding of SQL vs NoSQL

🎭 Two Main Database Types

📊

Relational Databases (SQL)

Structured, table-based systems

Think of relational databases likespreadsheets with superpowers! 📈 Data is organized in tables with strict relationships.

Key Characteristics:

  • 📋 Data stored intables(rows and columns)
  • 🔗Relationshipsbetween tables
  • ACID compliance(data integrity)
  • 🔍 UsesSQL(Structured Query Language)
  • 📐Fixed schema(predefined structure)

✅ Advantages

  • Data consistency
  • Complex queries
  • Mature technology
  • Strong data integrity
  • Standardized language

❌ Disadvantages

  • Rigid structure
  • Harder to scale
  • Schema changes difficult
  • Can be slower for big data

🎯 Perfect For:

  • E-commerce sites (orders, inventory)
  • Banking systems (transactions)
  • CMS like WordPress
  • Any app needing data relationships

Popular Examples:

MySQL PostgreSQL SQLite Oracle SQL Server
📄

Non-Relational Databases (NoSQL)

Flexible, document-based systems

Think of NoSQL databases likeflexible filing systems! 📁 Data can be stored in various formats without strict rules.

Key Characteristics:

  • 📄 Various formats (documents, key-value, graph)
  • 🔄Flexible schema(or no schema)
  • Horizontal scaling(add more servers)
  • 🚀 Optimized forbig data
  • 🎯 Different query languages

✅ Advantages

  • Flexible structure
  • Easy to scale
  • Fast for simple queries
  • Handles unstructured data
  • Great for real-time apps

❌ Disadvantages

  • Less mature
  • Limited complex queries
  • Potential data duplication
  • Less standardization

🎯 Perfect For:

  • Social media platforms
  • Real-time analytics
  • IoT data collection
  • Content management
  • Gaming leaderboards

Popular Examples:

MongoDB Redis Cassandra Firebase DynamoDB

🔍 SQL vs NoSQL: Visual Comparison

graph TB subgraph "SQL Database" A[Users Table] B[Orders Table] C[Products Table] A -->|user_id| B B -->|product_id| C end subgraph "NoSQL Database" D[User Document
contains orders
and preferences] E[Product Document
contains reviews
and inventory] end style A fill:#667eea,color:white style B fill:#667eea,color:white style C fill:#667eea,color:white style D fill:#10b981,color:white style E fill:#10b981,color:white
Aspect Relational (SQL) Non-Relational (NoSQL)
Data Model Tables with rows and columns Documents, key-value, graph, column
Schema Fixed, must be defined upfront Dynamic, flexible
Query Language SQL (standardized) Database-specific
Scalability Vertical (bigger server) Horizontal (more servers)
ACID Compliance Yes (guaranteed) Sometimes (depends on DB)
Best For Complex relationships Large amounts of varied data

🎯 Choosing the Right Database

Ask Yourself These Questions:

  1. Do I need ACID compliance?→ SQL
  2. Will my data structure change often?→ NoSQL
  3. Do I need complex queries and reports?→ SQL
  4. Am I dealing with huge amounts of unstructured data?→ NoSQL
  5. Is my team familiar with SQL?→ SQL might be easier

🌐 WordPress and MySQL

Why WordPress Uses MySQL (Relational Database)

WordPress chose MySQL because:

  • 📊Structured Content:Posts, pages, users all have defined relationships
  • 🔗Complex Relationships:Users → Posts → Comments → Categories
  • Data Integrity:Important for content management
  • 🌍Wide Support:Available on almost all web hosts
  • 💰Free & Open Source:No licensing costs
  • Performance:Fast enough for most websites

WordPress Database Tables:

wp_posts      → All posts and pages
wp_users      → User accounts
wp_comments   → Comments on posts
wp_options    → Site settings
wp_postmeta   → Additional post data
wp_usermeta   → Additional user data
wp_terms      → Categories and tags
wp_termmeta   → Category/tag metadata

🎮 Interactive Exercise

Match the Database Type

Which database type would be best for these scenarios?

1. Online banking system

Needs transactions, data integrity

2. Social media feed

Flexible content, real-time updates

3. E-commerce inventory

Product-order relationships, transactions

🎯 Key Takeaways

  • SQL databases use structured tables with relationships
  • NoSQL databases offer flexibility and scalability
  • SQL is best for complex relationships and transactions
  • NoSQL excels with large amounts of varied data
  • WordPress uses MySQL (SQL) for its structured content
  • Choose based on your specific needs, not trends

📚 Next Steps

Now that you understand database types, let's dive into:

  • Introduction to MySQL specifically
  • Why MySQL is perfect for web development
  • MySQL features and capabilities
Continue to Introduction to MySQL →