Code Monkey home page Code Monkey logo

orms-quiz's Introduction

Quiz: ORM

???

ORM

?: Object Relational Mapping (ORM) is the technique of accessing a relational database using what type of programming language?

( ) SQL ( ) Ruby ( ) BASH (X) Object-Oriented

?: What Ruby method can be used to insert data into the database?

( ) .insert ( ) .add (X) .save ( ) .update

?: To follow a pattern of logical design, if we have a Car class, what should the table be named?

(X) cars ( ) make ( ) model ( ) vehicle

?:

class Car

  attr_accessor :make, :model

  def initialize(make, model)
    @make = make
    @model = model
  end

end

In order to "map" this Car class to a cars database table, what needs to be done first?

( ) Create a cars table (X) Create a database ( ) Make a .create_table method ( ) Add an id argument to the #initialize method that defaults to nil.

?: Which method would update the database row mapped to the given instance?

( ).save (X).update ( ).find ( )self

?: To set a constant named DB that contains a connection to a database, which syntax should be used?

( )

DB = {conn => SQLite3::Database.new("db/database.db")}

( )

DB = {:conn => SQLite3::Database("db/database.db")}

( )

db = {:conn => SQLite3::Database.new("db/database.db")}

(X)

DB = {:conn => SQLite3::Database.new("db/database.db")}

?: To map a class to a database table, create a table with the same name as the class and give use table column names that match the attr_accessors of the class.

(X) True ( ) False

?:

| id | make | model |

Which code snippet maps the instance attributes to these table columns?

( )

class Car

  attr_accessor :make, :model, :id

  def initialize(make, model, id)
    @id = id
    @make = make
    @model = model
  end

end

( )

class Car

  def initialize(make, model, id=nil)
    @id = id
    @make = make
    @model = model
  end

end

(X)

class Car

  attr_accessor :make, :model, :id

  def initialize(make, model, id=nil)
    @id = id
    @make = make
    @model = model
  end

end

( )

class Car

  def initialize(make, model, id)
    @id = id
    @make = make
    @model = model
  end

end

?: It is best to save a new record when a new object is created, i.e. in the #initialize method.

( ) True (X) False

???

orms-quiz's People

Contributors

drakeltheryuujin avatar maxwellbenton avatar rrcobb avatar vibraniumforge avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.