Database Reference
In-Depth Information
Persistence basics
Up to this point, we have delved heavily into MSMQ. In later chapters, we will also cover
RabbitMQ and ActiveMQ. If you know MSMQ very well, learning RabbitMQ and Act-
iveMQ will be simple, except that these technologies are not as tightly coupled to the Win-
dows Server as MSMQ.
Let's face it: as a developer, and architect, you are likely reading this chapter to keep up
your skills. Your skills get you jobs. If you are skilled in both Java and C#, your chances of
getting employment is greater. The same logic applies if you know how to build enterprise
systems not only using message queues, but databases as well. It will be easier to find serv-
er people who can administrate the databases rather than message queue systems simply
because databases are prevalent in storing data for a multitude of desktop systems as well.
Therefore, you may want to use databases for message queuing. Most projects spend a lot
of time persisting data to the databases and building tables and databases, which we discuss
through this chapter. However, we will not run SQL commands in this chapter; rather, we
will build objects on top of C# frameworks to deal with SQL commands. In many modern
technologies these days, such as NServiceBus, Entity Frameworks, NHibernate, and Spring
Roo, the frameworks run a lot of SQL commands. We use objects in these frameworks, and
the frameworks either generate DDLs, XML mapping, or scripting. NSB will take care of
most of the mappings to the databases directly.
One of the reasons, besides heavily loading SQL Servers with stored procedures, for the
object relational mappers
(
ORMs
) being more and more popular and also NoSQL data-
bases such as RavenDB and MongoDB, is not just to take advantage of having modern
frameworks do the heavy lifting, but to have the tools in the frameworks do the heavy pro-
cessing. SQL Server, and other databases, seem to always have enough load.
The concept is to create the objects in code, and the frameworks will take care of the SQL.
This allows developers to code faster once they get used to the frameworks. Some of the
fathers of agile processes developed frameworks such as Spring for all developers to glue
frameworks as opposed to building everything from scratch. The other reason is SQL Injec-
tion. Feel free to go through some of my slides to understand some of this,
ht-
tp://www.slideshare.net/rhelton_1/asp-mvs3-rev009
. Here's a slide for a starting iPad de-
velopment in C#,
http://www.slideshare.net/rhelton_1/the-ipad-monotouch
. Here's an older
slide on NServiceBus,
http://www.slideshare.net/rhelton_1/nservicebus
.
If SQL commands
are in code, and used close to the frontend of an application, a hacker can try to inject SQL