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

code challenge won't accept my mysql code

the code challenge on the keys and auto-increment won't accept: create table t_genres( pk_id integer auto_increment primary key, uk_name unique key varchar(55));

It continues to say I didn't do the pd_id right.

2 Answers

geoffrey
geoffrey
28,736 Points

It seems you forgot to put the NOT NULL condition.

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

geoffrey that worked. Wish they would have told you to put not null. Especially after they told us that it wasn't necessary for a primary key. Still a great tutorial.

geoffrey
geoffrey
28,736 Points

Yes, you are right about that, I honestly went through this tutorial some months ago, but I remember I had the same thought. Anyway, as far as we know It's not necessary to add it... that's the matter. I guess they specify to use it in the exercise to be sure we know how to use it. But, that would have been better to ask us to provide that for the uk_name column. In fact I've just figured out I specified as well NOT NULL for this column, but this isn't needed to pass the exercise. Keep it up, that course gave a me good basic knowledge of SQL for my little PHP projects.

Thanks Geoffrey. I'll try that.

geoffrey
geoffrey
28,736 Points

Yep, no worries, I verified in the meantime and that works as it should.