A good starting point for the database schema would be to have three tables: ‘Users’ for user data, ‘Products’ for product listings, and ‘Orders’ to link users to their purchased products. Each table should have a primary key, and foreign keys can be used to establish relationships between them.
In depth
When designing a schema for an e-commerce app, it's important to consider normalization to avoid redundancy. The 'Users' table might include fields for user ID, name, email, and password. The 'Products' table would typically have product ID, name, description, price, and stock quantity. The 'Orders' table can link to both 'Users' and 'Products' through foreign keys, storing order ID, user ID, product ID, and order date. Using foreign keys ensures referential integrity, helping maintain valid relationships between users and their orders. Considerations for scaling should also be made; for example, adding indexes to frequently queried fields can improve performance as the app grows.
Example scenario
In a real-world context, I worked on an e-commerce platform where we had to optimize our database schema as user registrations increased. Initially, the design was flat with no clear relationships established, leading to data duplication and slower queries. By introducing the three tables with proper foreign key constraints, we not only improved the integrity of the data but also enabled faster joins when querying user orders, enhancing the overall user experience during checkout.
Common mistakes
A common mistake is neglecting to use foreign keys, which can lead to orphan records and data integrity issues. Developers may also attempt to keep all user-related information in a single table, creating a monolithic structure that makes future changes difficult. Another frequent oversight is not indexing frequently searched columns, which can result in performance bottlenecks as the data volume grows.
Follow-up questions
- What normalization level would you target for this schema?
- How would you handle product categories in this design?
- Can you explain the benefits of using indexes in your tables?
- What considerations would you have for scaling this database as the user base grows?

Want all 2,000 questions in one PDF?
- Short answers, in-depth explanations, common mistakes and follow-ups
- 89 topics, from Beginner to Architect, with a clickable contents list
- 226 extra questions that are not on this website
- Free Bonus Pack: 30-day study plan, behavioral questions, salary scripts
Includes 226 extra questions that are not on this site, plus a free Bonus Pack.
Get both books for $9.99 (save $2.99):
The material stays free to read online. This is the organised, offline, print-ready PDF edition. Secure payment by PayPal; your personal download link is emailed after payment is confirmed. Digital product, no shipping.