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

Development Tools Database Foundations Joining Relational Data Between Tables in SQL Keys and Auto-Incrementing Values

My answer doesn't pass. I've copied the command into mysql workbench and the table is created with no issues;

The command works fine in Mysql Workbench; i'm not sure if this is a bug or i need to format my script a little bit differently.

CREATE TABLE t_genres (pk_id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, uk_name VARCHAR(45) NOT NULL);

Error Message: There's something wrong with the definition of your column named 'uk_name'. on some occasions if i make other adjustments i would also get an error that says pk_id does not have a primary key

2 Answers

Julian Aramburu
Julian Aramburu
11,368 Points

I think you have to set your uk_name column to "UNIQUE KEY" as it says "...and a unique column called "uk_name" that can't be null...." so after your "NOT NULL" you need to add "UNIQUE KEY" also I think you could only add UNIQUE KEY as UNIQUE KEYS cant be null.

Hope it helps :D!

Cheers and Keep Coding!

Thanks Julian! it worked in the code challenge, do you have any idea why it worked in MYSQL Workbench and not on Treehouse?

Julian Aramburu
Julian Aramburu
11,368 Points

it could be because you are asked to create an UNIQUE column... and you weren't creating one... It's going to work in your workbench because you are not forced to create anything specific

Julian Aramburu
Julian Aramburu
11,368 Points

Hi mate! it would be helpful if you paste your code in order to check it!

Cheers!

CREATE TABLE t_genres (pk_id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, uk_name VARCHAR(45) NOT NULL);

Error Message: There's something wrong with the definition of your column named 'uk_name'. on some occasions if i make other adjustments i would also get an error that says pk_id does not have a primary key