Showing posts with label Database. Show all posts
Showing posts with label Database. Show all posts

Monday, 12 October 2026

MariaDB Essentials: 5 Fun Quiz Questions + 3 SQL Practice Problems (with Answers)

 

MariaDB is one of the most popular open-source relational databases, created by MySQL's original founder, Michael "Monty" Widenius. It is known for high performance, stability, and strong MySQL compatibility. Major platforms like Wikipedia and WordPress.com rely on it.

Below are 5 multiple-choice questions and 3 SQL practice problems to help you quickly master MariaDB essentials.


Part 1: MariaDB Fun Quiz Questions

1. What animal is the MariaDB mascot?

  • A. A sea lion

  • B. A dolphin

  • C. An elephant

  • D. A penguin

Answer: A. A sea lion

MariaDB chose the sea lion as its mascot after founder Monty encountered a playful sea lion off the coast of Cape Town, South Africa. The sea lion continues the open-source tradition of animal symbols, and MariaDB itself is named after Monty's younger daughter, Maria.


2. What is the latest LTS release of MariaDB Server?

  • A. 12.3

  • B. 12.2

  • C. 10.11

  • D. 11.8

Answer: D. 11.8

MariaDB 11.8 is the annual Long-Term Support (LTS) release for 2025, officially launched in June 2025. It is the first LTS version with native MariaDB Vector support, providing a stable foundation for AI workloads.


3. What do MariaDB and MySQL have in common?

  • A. Nothing, they are unrelated projects

  • B. They share a release schedule

  • C. The same original creator

  • D. They are owned by the same company

Answer: C. The same original creator

Both MariaDB and MySQL were created by Michael "Monty" Widenius. After Oracle acquired MySQL in 2009, Monty created MariaDB as a fork of MySQL out of concern for open-source freedom. Many original MySQL developers joined the new project.


4. MariaDB now has native vector search for AI workloads. Which of these is a real MariaDB data type?

  • A. VECTOR

  • B. NEURAL

  • C. EMBEDDING

  • D. TENSOR

Answer: A. VECTOR

MariaDB introduced native vector search starting with version 11.7 and defined the VECTOR data type. It supports efficient nearest-neighbor search and cosine similarity calculations. This feature is fully supported in the 11.8 LTS release, with no extra plugins or separate vector database required.


5. How do you switch MariaDB into Oracle compatibility mode?

  • A. You need MariaDB Enterprise for that

  • B. INSTALL PLUGIN oracle_compat;

  • C. SET SQL_MODE=ORACLE;

  • D. ALTER DATABASE SET DIALECT ORACLE;

Answer: C. SET SQL_MODE=ORACLE;

Run SET SQL_MODE=ORACLE; to enable Oracle compatibility mode. MariaDB automatically activates a set of compatibility settings that support Oracle PL/SQL syntax, data types, and stored procedures, making migration from Oracle much easier.


6. Which technology gives MariaDB synchronous multi-master clustering out of the box?

  • A. MaxScale

  • B. Spider

  • C. Galera

  • D. ColumnStore

Answer: C. Galera

MariaDB Enterprise Cluster is built on Galera Cluster technology, providing true synchronous multi-master replication. Any node can read and write, and transactions are certified across all nodes before commit, ensuring zero data loss.


Part 2: SQL Practice Problems

Problem 1: Find the Oldest Departments

Task: Retrieve the name and established year of the oldest departments from the departments table.

sql
SELECT name, established
FROM departments
WHERE established = (SELECT MIN(established) FROM departments);

Problem 2: Calculate Age at Enrollment

Task: Retrieve student information from the students table and calculate age_at_enrollment.

sql
SELECT 
    student_number,
    first_name,
    last_name,
    date_of_birth,
    enrollment_date,
    TIMESTAMPDIFF(YEAR, date_of_birth, enrollment_date) AS age_at_enrollment
FROM students;

Problem 3: Filter NASA-Funded Active Research Projects

Task: Retrieve active research projects funded by NASA from the research_projects table.

sql
SELECT title, start_date, end_date
FROM research_projects
WHERE status = 'active' 
  AND funding_agency = 'NASA';

Part 3: How Can the MariaDB Foundation Be More Visible and Useful in Your Community?

The MariaDB Foundation can improve visibility and usefulness by:

  • Lowering the barrier to contribution: Offering more beginner-friendly tasks and documentation to encourage non-developers to participate in testing, translation, and community Q&A

  • Strengthening enterprise partnerships: Inviting more companies to become sponsoring members to drive feature customization and long-term support

  • Localizing community events: Hosting MariaDB meetups and tech talks in more regions so developers can learn about new features like AI vector search


Suggested Searches & Related Links

You can paste these searches directly into Google:

Related Web Links:


Conclusion

MariaDB not only inherits MySQL's ecosystem compatibility but also keeps innovating with vector search, Oracle compatibility, and clustering solutions. Whether you are migrating a legacy system or building AI applications, MariaDB is worth serious consideration.

Tuesday, 10 March 2026

Building Modern Web Applications with Angular and PocketBase: A Complete Guide

 


In today's fast-paced development world, choosing the right tech stack can make or break your project timeline. While Angular remains one of the most powerful frontend frameworks, developers often struggle with backend setup complexity. Enter PocketBase – an open-source backend that gives you authentication, database, and file storage in a single file.

In this guide, I'll show you how to build a complete web application using Angular + PocketBase, combining the best of both worlds.


Why Angular + PocketBase?

Angular Benefits:

  • Full-featured MVC framework with TypeScript support

  • Built-in dependency injection

  • Powerful CLI for scaffolding

  • RxJS for reactive programming

  • Enterprise-ready architecture

PocketBase Benefits:

Perfect For:

  • MVPs and startups needing rapid development

  • Internal tools and dashboards

  • E-commerce applications

  • Content management systems

  • Real-time collaborative apps


Prerequisites

Before we begin, ensure you have:

  • Node.js (v18 or later)

  • Angular CLI (npm install -g @angular/cli)

  • PocketBase executable (download from pocketbase.io)

  • Basic knowledge of TypeScript and Angular


Step 1: Setting Up PocketBase

1. Download and Install

bash
# For Linux/Mac
wget https://github.com/pocketbase/pocketbase/releases/download/v0.22.0/pocketbase_0.22.0_linux_amd64.zip
unzip pocketbase_0.22.0_linux_amd64.zip

# For Windows
# Download the .exe file from GitHub releases

2. Start PocketBase

bash
./pocketbase serve

Your PocketBase server will run at http://127.0.0.1:8090. Visit the admin UI at http://127.0.0.1:8090/_/ and create your admin account.

3. Create Your First Collection
In the admin UI, create a new collection called posts with fields:

  • title (text, required)

  • content (text, required)

  • published (boolean, default false)

  • created (date, auto)


Step 2: Creating Angular Application

1. Generate New Angular Project

bash
ng new angular-pocketbase-app --style=css --routing
cd angular-pocketbase-app

2. Install PocketBase SDK

bash
npm install pocketbase

3. Create PocketBase Service
Generate a service to handle all PocketBase interactions:

bash
ng generate service services/pocketbase

4. Configure Environment Variables
Update src/environments/environment.ts:

typescript
export const environment = {
  production: false,
  pocketBaseUrl: 'http://127.0.0.1:8090'
};

Step 3: Building the PocketBase Service

src/app/services/pocketbase.service.ts

typescript
import { Injectable } from '@angular/core';
import PocketBase from 'pocketbase';
import { environment } from '../../environments/environment';

@Injectable({
  providedIn: 'root'
})
export class PocketbaseService {
  private pb: PocketBase;

  constructor() {
    this.pb = new PocketBase(environment.pocketBaseUrl);
  }

  // Authentication methods
  async login(email: string, password: string) {
    return await this.pb.collection('users').authWithPassword(email, password);
  }

  async register(email: string, password: string, passwordConfirm: string) {
    return await this.pb.collection('users').create({
      email,
      password,
      passwordConfirm
    });
  }

  logout() {
    this.pb.authStore.clear();
  }

  get currentUser() {
    return this.pb.authStore.model;
  }

  // Posts CRUD operations
  async getPosts() {
    return await this.pb.collection('posts').getFullList({
      sort: '-created',
      filter: 'published = true'
    });
  }

  async createPost(data: any) {
    return await this.pb.collection('posts').create(data);
  }

  async updatePost(id: string, data: any) {
    return await this.pb.collection('posts').update(id, data);
  }

  async deletePost(id: string) {
    return await this.pb.collection('posts').delete(id);
  }

  // Real-time subscriptions
  subscribeToPosts(callback: (data: any) => void) {
    return this.pb.collection('posts').subscribe('*', (e) => {
      callback(e);
    });
  }
}

Step 4: Creating Components

1. Posts List Component

bash
ng generate component posts-list

src/app/posts-list/posts-list.component.ts

typescript
import { Component, OnInit, OnDestroy } from '@angular/core';
import { PocketbaseService } from '../services/pocketbase.service';

@Component({
  selector: 'app-posts-list',
  templateUrl: './posts-list.component.html',
  styleUrls: ['./posts-list.component.css']
})
export class PostsListComponent implements OnInit, OnDestroy {
  posts: any[] = [];
  private unsubscribe: any;

  constructor(private pb: PocketbaseService) {}

  async ngOnInit() {
    await this.loadPosts();
    this.setupRealtime();
  }

  async loadPosts() {
    this.posts = await this.pb.getPosts();
  }

  setupRealtime() {
    this.unsubscribe = this.pb.subscribeToPosts((data) => {
      console.log('Realtime update:', data);
      this.loadPosts(); // Reload posts on any change
    });
  }

  ngOnDestroy() {
    if (this.unsubscribe) {
      this.unsubscribe();
    }
  }
}

src/app/posts-list/posts-list.component.html

html
<div class="posts-container">
  <h2>Latest Posts</h2>
  <div class="posts-grid">
    <div *ngFor="let post of posts" class="post-card">
      <h3>{{ post.title }}</h3>
      <p>{{ post.content }}</p>
      <small>Published: {{ post.created | date }}</small>
    </div>
  </div>
</div>

Step 5: Adding Authentication UI

1. Login Component

bash
ng generate component login

src/app/login/login.component.ts

typescript
import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { PocketbaseService } from '../services/pocketbase.service';

@Component({
  selector: 'app-login',
  templateUrl: './login.component.html',
  styleUrls: ['./login.component.css']
})
export class LoginComponent {
  email = '';
  password = '';
  error = '';

  constructor(
    private pb: PocketbaseService,
    private router: Router
  ) {}

  async onSubmit() {
    try {
      await this.pb.login(this.email, this.password);
      this.router.navigate(['/posts']);
    } catch (err: any) {
      this.error = err.message || 'Login failed';
    }
  }
}

Step 6: Real-time Features with RxJS

PocketBase's real-time capabilities work beautifully with Angular's RxJS. Here's an enhanced service using Observables:

typescript
import { Observable } from 'rxjs';

// In pocketbase.service.ts
watchPosts(): Observable<any> {
  return new Observable((observer) => {
    const unsubscribe = this.pb.collection('posts').subscribe('*', (data) => {
      observer.next(data);
    });
    
    return () => unsubscribe();
  });
}

Now you can use this in components:

typescript
this.pb.watchPosts().subscribe(update => {
  console.log('Real-time update:', update);
  // Update your local data accordingly
});

Step 7: Deployment Considerations

Building Angular for Production

bash
ng build --prod

Deploying PocketBase

  1. Upload PocketBase binary to your VPS or cloud server

  2. Set up as a systemd service for auto-restart

  3. Configure environment variables

  4. Use Nginx as reverse proxy for SSL

Sample systemd service file:

ini
[Unit]
Description=PocketBase service

[Service]
Type=simple
User=youruser
WorkingDirectory=/opt/pocketbase
ExecStart=/opt/pocketbase/pocketbase serve --http=0.0.0.0:8090
Restart=on-failure

[Install]
WantedBy=multi-user.target

Step 8: Security Best Practices

  1. Environment Variables: Never hardcode credentials

  2. CORS Configuration: Configure PocketBase CORS properly

  3. Validation Rules: Set collection validation rules in PocketBase admin

  4. API Rules: Implement proper collection permissions

  5. HTTPS: Always use SSL in production


Conclusion

Angular + PocketBase creates a powerful, modern stack that significantly reduces development time while maintaining scalability and performance. PocketBase handles all backend complexity, letting you focus on building amazing Angular applications.

Key Takeaways:

  • PocketBase provides instant backend with zero configuration

  • Angular offers robust structure for large applications

  • Real-time features are simple to implement

  • Perfect for startups and MVPs

  • Open-source and self-hosted (no vendor lock-in)


Next Steps

  • Explore PocketBase's file upload capabilities

  • Implement OAuth authentication (Google, GitHub)

  • Add search functionality

  • Build an admin dashboard

  • Deploy to production with Docker