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

We're starting a rock collectors club! Can you create a 'members' table with the following column

I created the id as a primary key but it did not work . What did i do wrong?

CREATE TABLE MEMBERS(ID PRIMARY KEY,FIRST_NAME,LAST_NAME,FAVORITE_ROCK);

5 Answers

I tried it several times yesterday with types and without types but it did not work . Anyway i tried it again with types last night and it worked perfect . Thank you very much

Can you post the error you're getting? While not required in SQLite, I still would add the data type for each column. Maybe that's what the challenge is expecting, but I'd have to see the question and error.

I know you have found the answer but for everyone else that may be struggling and not sure I thought it might be good to put my code that worked and explain what's happening

CREATE TABLE MEMBERS( // creating a table called members

ID UNIQUE , // creating the column 'id' and making it unique with the 'UNIQUE' constraint (link to informative page below)

FIRST_NAME, //creating first name column

LAST_NAME, // creating last name column

FAVORITE_ROCK // creating favorite rock column

); // closing the parentheses

What is a Unique constraint? : https://www.w3schools.com/sql/sql_unique.asp

Happy coding :)

Ruan Davis
Ruan Davis
7,344 Points

I have also tried it, however you need to assemble your code in a line. CREATE TABLE MEMBERS(ID PRIMARY KEY,FIRST_NAME,LAST_NAME,FAVORITE_ROCK); and add the data types as well. that's what i have done and it worked.

This worked for me; after much fiddling around I realised that I had accidentally left a comma at the end of the favourite_rock column.

CREATE TABLE members (
id SMALLINT PRIMARY KEY,
first_name VARCHAR(255),
last_name VARCHAR(255),
favorite_rock VARCHAR(255)
);