agentsclimarketplace

Backend database

Skill Genuineh/fus/skills/backend-database

Database Design and Selection Guide. Provides guidance for database selection and schema design for different use cases.From its SKILL.md

Install
npx -y skills add Genuineh/fus --skill backend-database

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

3.5 KB, as published. Nobody here has run it

Database Design and Selection

Guide for database selection and schema design.


Database Selection

Decision Matrix

Use CaseRecommendedAlternative
Transactional (OLTP)PostgreSQL, MySQLCockroachDB
Analytical (OLAP)ClickHouse, BigQueryPostgreSQL + extensions
Document storeMongoDB, PostgreSQL JSONCouchDB
Key-ValueRedis, etcdDynamoDB
GraphNeo4jPostgreSQL + graph
Time seriesInfluxDB, TimescaleDBPostgreSQL
CacheRedisMemcached
SearchElasticsearch, MeilisearchPostgreSQL full-text

Selection Criteria

  1. Data Model

    • Structured (SQL) vs Unstructured (NoSQL)
    • Relations required?
  2. Consistency Needs

    • ACID required? → SQL
    • Eventual OK? → NoSQL
  3. Scale

    • Single node? → PostgreSQL/MySQL
    • Distributed? → CockroachDB, MongoDB
  4. Latency

    • Sub-ms? → Redis
    • ms OK? → PostgreSQL

Schema Design Principles

Normalization

LevelDescriptionUse When
1NFAtomic valuesAlways
2NFNo partial dependenciesWith composite keys
3NFNo transitive dependenciesMost cases
BCNFBoyce-CoddWhen strict

Denormalization

When to denormalize:

  • Read-heavy workloads
  • Performance-critical queries
  • Reporting/analytics

Common Patterns

-- Star schema for analytics
CREATE TABLE fact_orders (
    id BIGSERIAL PRIMARY KEY,
    user_id BIGINT REFERENCES users(id),
    product_id BIGINT REFERENCES products(id),
    store_id BIGINT REFERENCES stores(id),
    quantity INT,
    total_amount DECIMAL(10,2),
    created_at TIMESTAMP
);

-- Dimension tables
CREATE TABLE dim_users (...);
CREATE TABLE dim_products (...);
CREATE TABLE dim_stores (...);

SQL Best Practices

Indexing

-- Composite index for common query
CREATE INDEX idx_orders_user_date
ON orders(user_id, created_at DESC);

-- Partial index
CREATE INDEX idx_active_users
ON users(id) WHERE status = 'active';

-- Avoid over-indexing
-- Each index slows writes

Query Patterns

-- Good: Use EXISTS instead of IN
SELECT * FROM users u
WHERE EXISTS (SELECT 1 FROM orders o WHERE o.user_id = u.id);

-- Avoid: SELECT *
SELECT id, name, email FROM users;

-- Good: Batch operations
INSERT INTO items (name) VALUES
('a'), ('b'), ('c');

-- Pagination
SELECT * FROM users
ORDER BY id LIMIT 10 OFFSET 100;

NoSQL Patterns

Document (MongoDB)

// Embedding vs Referencing
// Embed: One-to-few
{
  name: "Order",
  items: [
    { product: "Book", qty: 2 },
    { product: "Pen", qty: 1 }
  ]
}

// Reference: One-to-many
{
  user_id: 123,
  orders: [1, 2, 3]  // Array of IDs
}

Key-Value (Redis)

// Use for:
// - Session cache
// - Rate limiting
// - Leaderboards

// Example: Rate limiter
async fn check_rate_limit(key: &str, limit: u32, window: Duration) -> bool {
    let count = redis.incr(key).await?;
    if count == 1 {
        redis.expire(key, window).await?;
    }
    Ok(count <= limit)
}

Data Modeling Checklist

  • Data model selected
  • Normalization level decided
  • Indexes planned
  • Query patterns analyzed
  • Migration strategy defined
  • Backup strategy defined
  • Performance requirements set

Keep looking

Skills are one crate of 607,533. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.