In the information age, with new technologies, frameworks, and programming languages, there is an aspect of technology that never changes. All applications need a storage integration related to their system; either SQL or NoSQL, to point out that there is a different paradigm among the development team and the database team. To make developer life easier, new frameworks emerged that convert between the application layer and the database, which includes the famous ORM. Indeed, contemporary challenges appear such as how to handle different paradigms that are in software development and how to make a regular development without impacting on the database.
12. Mapper
Real entities are not database structure
Less Database means bad database
design
Less boilerplate is not magic
Domain is not Database
13. Active Record
● Simple
● Easy to learn
public class Person extends Model {}
Person person = new Person("Ada","Lovelace");
person.saveIt();
Person ada = Person.findFirst("name = ?", "Ada");
String name = ada.get("name");
ada.delete();
List<Person> people = Person.where("name = 'Ada'");
14. Active Record
● Database Coupling
● Performance
bottlenecks
● Transactions?
● Connections?
● Pool?
15. Mapper
@Entity
public class Person {
private @Id String name;
private @Column String lastName;
}
EntityManager manager = getEntityManager();
manager.getTransaction().begin();
Person person = new Person("Ada","Lovelace");
manager.persist(person);
manager.getTransaction().commit();
List<Person> people = manager.createQuery("SELECT p from Person where
p.name = @name").setParameter("name", "Ada").getResultList();
● Flexibility
● Performant
19. Keys
The AUTOINCREMENT keyword imposes extra CPU, memory, disk space, and disk I/O overhead and
should be avoided if not strictly needed. It is usually not needed.
● Performance
● Security
● Compound key
● UUID?
30. Summary
● Impact
● Volumetry
● Active Record vs Object
Mapper
● Design outside the code
● Know-how vs Know-why
● Index
● Model to Data
● Trade-offs
● DBA is not your enemy