1
CSE 3901 FINAL – RAILS NEWEST ACTUAL 2025/2026
UPDATED EXAM WITH COMPLETE QUESTIONS AND
ANSWERS.VERIFED/GRADED A+
MVC Pattern - (ANSWER)A pattern that separates a program into the data, the
observer and the controller
Model
- The data (i.e. state)
- Methods for accessing and modifying state
View
- Renders contents of model for user
- When model changes, view must be updated
Controller
- Translates user actions (i.e. interactions with view) into operations on the model
- Example user actions: button clicks, menu selections
MVC in basic web application - (ANSWER)Model
- Database (table with rows)
- Classes that wrap database operations (class with instances)
View
- HTML (+ CSS, JavaScript) files rendered by client's browser
- Skeleton files used by server to generate these HTML files
Controller
- Receives HTTP requests via web server
, 2
- Orchestrates activity (model and view)
Mapping table to objects - (ANSWER)General strategy for OO languages:
- Table in database - a class
- Table columns - attributes of the class
- Table rows - instances of class (objects)
Database tables - (ANSWER)Database is a collection of tables
Each table has a list of columns
Each column has a name and a type
A table has a list of rows
Models - (ANSWER)Programmatic way for application to interact with database
- Model = a Ruby class
- Extends ApplicationRecord
- Found in app/models
Each class corresponds to a table
- Note: Models are singular (tables are plural)
- Includes attributes corresponding to columns implicitly
Class methods for Models - (ANSWER)Create a new instance with .new
Create instance and add it to database with .create
, 3
Retrieve particular rows from table with .find, .find_by, .all, .first, .last
Save a model as a row in database with .new followed by .save
Read/write attributes like ordinary class (e.g. p.title =... then p.save)
Delete a row from the table with .destroy (no save needed)
Which database to use? - (ANSWER)SQLite is the easiest (no setup)
MySQL has better performance
PostgreSQL favored for Heroku deployment
Table constraints - (ANSWER)Database is responsible for assigning unique
identifier for each row (a primary key, can't change after creation)
PRIMARY KEY, FOREIGN KEY, NOT NULL, NULL, UNIQUE, CHECK
Linking tables - (ANSWER)Different tables can be related to each other
Keys are used to encode this relationship
- E.g. Students table include a column identifying a student's major (foreign key)
Association is an invariant between tables
Schema (table structure) - (ANSWER)Table name
Column names and types
Constraints
CSE 3901 FINAL – RAILS NEWEST ACTUAL 2025/2026
UPDATED EXAM WITH COMPLETE QUESTIONS AND
ANSWERS.VERIFED/GRADED A+
MVC Pattern - (ANSWER)A pattern that separates a program into the data, the
observer and the controller
Model
- The data (i.e. state)
- Methods for accessing and modifying state
View
- Renders contents of model for user
- When model changes, view must be updated
Controller
- Translates user actions (i.e. interactions with view) into operations on the model
- Example user actions: button clicks, menu selections
MVC in basic web application - (ANSWER)Model
- Database (table with rows)
- Classes that wrap database operations (class with instances)
View
- HTML (+ CSS, JavaScript) files rendered by client's browser
- Skeleton files used by server to generate these HTML files
Controller
- Receives HTTP requests via web server
, 2
- Orchestrates activity (model and view)
Mapping table to objects - (ANSWER)General strategy for OO languages:
- Table in database - a class
- Table columns - attributes of the class
- Table rows - instances of class (objects)
Database tables - (ANSWER)Database is a collection of tables
Each table has a list of columns
Each column has a name and a type
A table has a list of rows
Models - (ANSWER)Programmatic way for application to interact with database
- Model = a Ruby class
- Extends ApplicationRecord
- Found in app/models
Each class corresponds to a table
- Note: Models are singular (tables are plural)
- Includes attributes corresponding to columns implicitly
Class methods for Models - (ANSWER)Create a new instance with .new
Create instance and add it to database with .create
, 3
Retrieve particular rows from table with .find, .find_by, .all, .first, .last
Save a model as a row in database with .new followed by .save
Read/write attributes like ordinary class (e.g. p.title =... then p.save)
Delete a row from the table with .destroy (no save needed)
Which database to use? - (ANSWER)SQLite is the easiest (no setup)
MySQL has better performance
PostgreSQL favored for Heroku deployment
Table constraints - (ANSWER)Database is responsible for assigning unique
identifier for each row (a primary key, can't change after creation)
PRIMARY KEY, FOREIGN KEY, NOT NULL, NULL, UNIQUE, CHECK
Linking tables - (ANSWER)Different tables can be related to each other
Keys are used to encode this relationship
- E.g. Students table include a column identifying a student's major (foreign key)
Association is an invariant between tables
Schema (table structure) - (ANSWER)Table name
Column names and types
Constraints