Hack hack hack...

An open journal-- some of it written for you, but most of it is for me.

FIS Day5

“Classes are state plus behavior, if you just want the behavior then use a module!”

This is no good: Singleton Object- class with one method on it
1
2
3
4
class Random
  def self.something
  end
end

Underuse of modules…

Programmer of the day

Dan Bricklin

  • inventor of the spreadsheet

Homework Review

table names should be plaural (e.g.table USERS)

id INTEGER PRIMARY KEY -> always be called ID, is an integer and auto increments

‘never use ruby for something SQL can do’

you want to group by integer values rather than string values

AS aliases the columns

subqueries- as long as a query returns one and only one value you can use that for another query

Visual explanation of sql

INDEXes

  • index a column when it is being used in columns or queries
  • should index foreign keys (they are not automatically indexed)
  • cost: everytime you add a record it has to reindex
  • indexes compromise the write speed in favor of read speed

Two optimization steps:

  • denormalize (add more columns)
  • index - optimize for write or read?

    • the more indexes your keys are using the more efficient your DB will be
  • You optimize the joins by denormalizing (and thus removing the need for joins) and indexing

This is no good: Singleton Object- class with one method on it
1
cp -r <old dir name> <new dir name>

update in SQL

This is no good: Singleton Object- class with one method on it
1
2
3
UPDATE Persons
SET Address='Nissestien 67', City='Sandnes'
WHERE LastName='Tjessem' AND FirstName='Jakob'

Transaction

Comments