RDBMSs in more detail later but in brief an RDBMS stores a collection of tables

Rdbmss in more detail later but in brief an rdbms

This preview shows page 90 - 92 out of 517 pages.

RDBMSs in more detail later, but in brief, an RDBMS stores a collection of tables , each of which stores entities with a common set of attributes . One row in the table corresponds to one entity, and the columns in that row correspond to the attribute values for that entity. The movies table for RottenPotatoes includes columns for title , rating , release_date , and description , and the rows of the table look like Figure 2.11 . id title rating release_date description 1 Gone with the Wind G 1939-12-15 An American classic ... 2 Casablanca PG 1942-11-26 Casablanca is a... Figure 2.11: A possible RDBMS table for storing movie information. The id column gives each row’s primary key or permanent and unique identifier. Most databases can be configured to assign primary keys automatically in various ways; Rails uses the very common convention of assigning integers in increasing order. Since it is the responsibility of the Models to manage the application’s data, some correspondence must be established between the operations on a model object in memory (for example, an object representing a movie) and how it is represented and manipulated in the storage tier. The in-memory object is usually represented by a class that, among other things, provides a way to represent the object’s attributes, such as the title and rating in the case of a movie. The choice made by the Rails framework is to use the Active Record architectural pattern . In this pattern, a single instance of a model class (in our case, the entry for a single movie) corresponds to a single row in a specific table of an RDBMS. The model object has built-in behaviors that directly operate on the database representation of the object: Create a new row in the table (representing a new object), Read an existing row into a single object instance, Update an existing row with new attribute values from a modified object instance, Delete a row (destroying the object’s data forever).
Image of page 90
This collection of four commands is often abbreviated CRUD . Later we will add the ability for moviegoers to review their favorite movies, so there will be a one-to-many relationship or association between a moviegoer and her reviews; Active Record exploits existing mechanisms in the RDBMS based on foreign keys (which we’ll learn about later) to make it easy to implement these associations on the in-memory objects. Summary One important job of the Model in an MVC SaaS app is to persist data, which requires converting between the in-memory representation of an object and its representation in permanent storage. Various design patterns have evolved to meet this requirement, many of them making use of structured storage such as Relational Database Management Systems (RDBMSs) to simplify not only the storage of model data but the maintenance of relationships among models.
Image of page 91
Image of page 92

You've reached the end of your free preview.

Want to read all 517 pages?

  • Spring '19
  • Dr.Marcos

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors