Todays mastery topic is about converting class designs to databas tables, this is also know as mapping
Understanding the purpose of your database will inform your choices throughout the design process. Make sure you consider the database from every perspective. For instance, if you were making a database for a public library, you’d want to consider the ways in which both patrons and librarians would need to access the data.
For this topic we are going to talk about Object-relational mapping (ORM) whish is a programming technique that lets you query and manipulate data from a database using an object-oriented chart. When talking about ORM, most people are referring to a library that implements the Object-relational mapping technique. An ORM library is a completely ordinary library written in your language of choice that encapsulates the code needed to manipulate the data, so you don’t use SQL anymore; you interact directly with an object in the same language you’re using.
Here comes some Pros & Cons about ORM
1. Using ORM saves a lot of time
- You only use one place to write your data model, this makes it easier to update, maintain and reuse code.
- Sanitizing: using prepared statements or transactions are as easy as calling a method
2. Using an ORM library is more flexible
- It fits in your natural way of coding
- The model is not bound to the rest of the application, so you can change it or use it anywhere else
Can be a pain to learn
- You have to learn it, and ORM libraries are not lightweight tools
- Performance is OK for usual queries, but there are faster options.