Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Databases

Juan Bolanos
Juan Bolanos
12,492 Points

Creating and Modifying Database Tables - Challenge 1 of 3

Am I an idiot or something? I can't figure out the correct answer to this question... 'In the last challenge we created a table for the members of our rock collecting club. Now, we'd like to add a ROCKS table to store information about our favorite rocks. Can you create a table named ROCKS with the following columns: ID, NAME, TYPE, COLOR. And make sure that ID is a primary key.

'I have tried multiple queries and for some reason neither work. What am I missing, am I blind?

Here are the queries I've tried: CREATE TABLE ROCKS(ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME VARCHAR(255), TYPE VARCHAR(255), COLOR VARCHAR(255));

CREATE TABLE ROCKS(ID INTEGER PRIMARY KEY, NAME VARCHAR(255), TYPE VARCHAR(255), COLOR VARCHAR(255));

CREATE TABLE ROCKS(ID PRIMARY KEY , NAME VARCHAR(255), TYPE VARCHAR(255), COLOR VARCHAR(255));

4 Answers

Ben Deitch
STAFF
Ben Deitch
Treehouse Teacher

Rest assured you are not an idiot! There was a problem with the CC that should be fixed now. Let me know if it's not, and thanks for pointing this out!

Juan Bolanos
Juan Bolanos
12,492 Points

That’s funny because I first inquired about the question to staff, Kara, about what I thought was a big. This was after spending time trying different answer and searching the forums, and finding posts about it being a bug. I was told that it wasn’t a big and that I put in the wrong answer. Surprise it was a big lol. The original answer now works.

I feel a lot better now knowing I’m not an idiot haha.

Daniele Fusari
Daniele Fusari
40,669 Points

HI BEN, I think this might not be working again?

Bummer SQL Error: UNIQUE constraint failed: ROCKS.ID

Ben Deitch
Ben Deitch
Treehouse Teacher

Well that IS a bummer. Either way, it should be fixed now!

Daniele Fusari
Daniele Fusari
40,669 Points

Thanks Ben. Realy enjoyed your course.

Mary Urban
Mary Urban
6,321 Points

I used exactly the hack listed above by Dale Severude and it didn't work in the challenge, but it worked in the playground just fine.

Steven Parker
Steven Parker
231,269 Points

Okay, here's the scoop. This challenge works when you omit column datatypes in a CREATE. SQLite doesn't actually use datatypes, which was covered in the first video of this course. But it normally treats them as a notation and does not cause an error.

I still think it's a bug in the course, particularly since it worked in earlier challenges to supply the datatypes, but you can get around it here by leaving them off.

You also don't need the "autoincrement", and be sure to enter the column names just like they were given: in lower case.

Juan Bolanos
Juan Bolanos
12,492 Points

Are we to assume that we should be writing as if using SQLlite and not MySQL or are both similar?

Ben Deitch
Ben Deitch
Treehouse Teacher

They're fairly similar, but we're looking for SQLite in the challenges.