Question: New to TDD here, d'oh!

Here's what I want to test ([ruby library](https://www.twilio.com/docs/ruby/install)), in brief:

```
 account = Twilio::RestAccount.new(ACCOUNT_SID, ACCOUNT_TOKEN)
    resp = account.request(
        "/#{API_VERSION}/Accounts/#{ACCOUNT_SID}/SMS/Messages",
        'POST',
        smsInfo
    )

```

And here's test code attempt:

```
describe Text do
  it "should call the Twilio API with credentials" do
    #pending "mocking api although not passed in.."
    t = mock(Twilio::RestAccount)
    twapi = mock("new twapi").should_receive(:request).and_return(Net::HTTPSuccess)
    t.stub(:new).and_return(twapi)

    Twilio::RestAccount.should_receive(:new)

    sms = Factory.create(:boring_sms)
    sms.send_sms
  end
end

```

which generates the error: undefined method `request' for nil:NilClass

Am I taking the right approach? thanks!

Answer: 
> 
> each concept would also have a table
> 
> 
> 

tables are not meant to be dynamic elements. of course they can be, but seriously.

a relational database structure has a static amount of tables.

please read about the [fundamentals of relational database design](http://www.deeptraining.com/litwin/dbdesign/FundamentalsOfRelationalDatabaseDesign.aspx)

the question whether you combine different entities in one table, and add a field to distinguish them, is very valid one. 

in the end i think it comes down to the application. it can seriously speed up things but also slow down. i prefer seperate tables because you save one index and may have it easier with sharding in fugure. UNION statements are cheap.

that being said. start with fixed objects, create tables for them.

create a table for "concepts" one for "ideas" one for "comments" one for "users" etc...

comments get a field for "idea" which idea they belong to etc.
You're looking for "foreign key references." You will likely find yourself with three tables: questions, answers, and comments on answers. Answers will have a field referencing the id of the question it's responding to, and likewise you will have a field in the comments table referencing the id of the answer it's responding to. I hope these links can be helpful:

[Wikipedia](http://en.wikipedia.org/wiki/Foreign_key)

[w3c](http://www.w3schools.com/sql/sql_foreignkey.asp)

This is an important area of database design that requires some heavier reading than it sounds like you're expecting.