惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
Netflix TechBlog - Medium
罗磊的独立博客
云风的 BLOG
云风的 BLOG
Last Week in AI
Last Week in AI
Y
Y Combinator Blog
小众软件
小众软件
Blog — PlanetScale
Blog — PlanetScale
T
The Blog of Author Tim Ferriss
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
月光博客
月光博客
博客园 - Franky
F
Fortinet All Blogs
D
Docker
博客园 - 司徒正美
腾讯CDC
Recent Announcements
Recent Announcements
The Cloudflare Blog
B
Blog RSS Feed
GbyAI
GbyAI
T
Tailwind CSS Blog
雷峰网
雷峰网
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 三生石上(FineUI控件)
阮一峰的网络日志
阮一峰的网络日志

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Struggling with Boyce-Codd Normal Form as a Junior Developer
barry odoro · 2026-06-18 · via DEV Community

barry odoro

I didn’t really think database design would be the part that slows me down. I expected JavaScript, maybe APIs, maybe deployment. Not tables.

But the moment I started trying to design an inventory system properly, I ran into something called Boyce-Codd Normal Form. BCNF sounded simple when I first read about it(No I'm kidding). Then I actually tried applying it, and everything started feeling even less clear.

At some point, I had a working schema. Products, sales, purchases, stock movements. It all worked. Kind of!
My first mistake was thinking normalization was about splitting tables until everything looks clean.

So I kept breaking things apart:

  • products table
  • categories table
  • sales table
  • sale items
  • purchases
  • stock

But I still had duplicated logic everywhere, especially around stock.

At some point I had both:

  • a stock table
  • a stock_movements table And I was updating both. Honestly I thought it was tradeoff or something(I know I'm stupid) but coincidentally I was also reading about database design(so not that stupid).

And then came BCNF

BCNF sounded like this abstract rule:

every determinant must be a candidate key

That sentence didn’t help me much at first.

What I understood instead was simpler:
if something depends on something that is not a key, you probably did something wrong.

Even that was still hard to apply.

And it only clicked when I started writing the events and triggers.
So the two sources of truth in my database didn't look that good.

I removed the stock table and replaced it with a view based on stock_movements.I used a view because stock was a derived quantity.So I eliminated duplication and stored one fact only.
**
Problems with other derived quantity**
So I initially thought that sales totals should be stored in the table,purchases table should store information about quantity and price and should I use triggers for certain things such as update the stock movements table after a sale, purchase or spoilage ,or should i implement it in the application logic.

I ended up coming back to the

one source of truth

so I did use triggers to update the stock_movements table.I also did not use derived quantities instead for the sales I decided I would have a header table and line items table -a sales and sale_item. The Sale table held the sale information(saleId,date,payment method,customer name, total), while the sale item held information about the products.Same applied to purchases.

What I learned

BCNF was the relationships we made along the way.