As a frontend or fullstack developer, what are some things you wish you knew about databases for building an app.<p>This could be anything like using connection strings, CLI tools, user Grants, GUI, writing optimised queries, adding indexes for performance, how SQL views can be leveraged etc.
The biggest thing is avoiding database structures that will be difficult to work with later, requiring data migrations to escape the dilemna.<p>The book SQL Antipatterns is a good read on this subject. But realistically, I think you need to work in a few production databases and experience these problems before you deeply understand them enough to understand why they are antipatterns.
- You cannot have a good database design without understanding the business requirements first<p>- Designing the code around the database leads to cleaner designs than doing it the other way around<p>- Almost all columns should be NOT NULL<p>- EXPLAIN helps you understand what the database does under the hood
Never store two different types of information in the same table, even if the structure is identical. They may be identical today -- they won't be in two years time.<p>If you're unsure about this, ask yourself if your table has a column called 'type' or something similar. If it does, a big migration awaits you a year or two down the road, and you'll have a lot of pain between now and then.