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

keys-and-autoincrementing-values

Create a genres table called "t_genres" with an auto incrementing primary key called "pk_id" and a unique column called "uk_name" that can't be null. The "uk_name" is a varchar of up to 45 characters.

http://teamtreehouse.com/library/programming/database-foundations/joining-relational-data-between-tables-in-sql/keys-and-autoincrementing-values-2

What am I doing wrong??

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

I Dont Understand

3 Answers

For starters, everything after t_genres should be wrapped in a set of parenthesis. Also, you can omit the ADD COLUMN. Not too sure where that came from. Next, you don't need the NOT NULL keywords because as an auto incrementing integer (hint hint: you need to specify the data type), it will always generate a number on its own. On the last column, uk_name, you have once again put the data type second. You should ALWAYS specify the data type first. In this second case, it's a VARCHAR.

You've got all the keywords right (sans the ADD COLUMN), you just need to review your syntax.

Happy MySQL'ing! Before you know it, you will have * of it memorized! ; )

I know that I dont need the ADD Column and the NOT null just trying to follow the video...

Thanks tho

Your first use of movie_id after the AS min_score alias is unnecessary. Your statement should read as:

SELECT MIN(score) AS min_score FROM reviews WHERE movie_id = 2;

James Corr
James Corr
2,678 Points

Stuck on this as well. I've got mine set up like this though:

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

....hmmm.

Also Andrew McCombs nice use of * (all) hahah I chuckled.