- What is the difference between ER modeling and object modeling?
- ER models represent data for relational databases: entities (tables), attributes (columns), relationships (foreign keys). Object models represent classes with behavior (methods) and inheritance. ORMs bridge the two by mapping classes to tables, though the paradigm mismatch (object-relational impedance) creates ongoing complexity.
- How do I handle many-to-many relationships in SQL?
- Many-to-many relationships (Student-Course, Author-Book) require a junction table (enrollment, authorship) with foreign keys to both entities. The junction table often has its own attributes (grade, role). ER diagrams show the relationship as a double-diamond or diamond with crow's feet.
- Should I normalize fully or denormalize for performance?
- Normalize to 3NF for OLTP (transactional) databases to maintain data integrity and avoid update anomalies. Denormalize (star schema, wide tables) for analytical (OLAP) databases where query performance matters more than write efficiency. Most production systems use both approaches for different access patterns.