Ask HN: Advice for a first-time DBA on a self-built e-commerce app?
But now I've built an ecommerce site that takes customer orders for a product, and I have to set up and manage my own database, and I'm nervous.
I know how easy it is to make a mistake as simple as a typo and screw up your schema or delete records, and with customers' money on the line I'm afraid to be in the position of making such mistakes.
In front-end development, I'm fairly well-versed on best practices and how to build a site that's sturdy and flexible and secure. I have no idea how to do any of those things with a database and am worried about falling into pits I don't know exist yet. SQL injection is the only pit I know to keep an eye out for.
How can I make the best of this? How can I become a competent DBA for myself when money's already on the line without screwing anyone over with amateur mistakes? Just looking for advice from anyone else who's had to do anything similar.
- For SQL injection, if you are using an ORM or library, it should have safe parameter binding for queries, make sure to follow its guidelines.
- It's mandatory to have an automated backup system for your database to ensure you can recover from any data loss scenario. Remember, a backup is only valid if you have tested to restore your database from it. So ideally your automated backup system should also check if the backup is working properly. I realize it's a lot of work, but it'll pay off when (not if) you encounter a disaster scenario that requires you to restore from backup.
At the very least, create an automated backup solution, and test it manually periodically to make sure it's working properly.
Store your backups in two or more separate places, if possible. Always encrypt your backups. You can check out Tarsnap.
DB's are generally very stable and don't need much maintenance. Most of your work really is from the dev side, schema design, good index placement.