• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating a recipe database (Step 1: Creating a database via MySQL)

 
Shakur Burton
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I started off on the wrong foot here when explaining myself on what I was trying to do, here. So, I'll try again from the ground up...

I've been trying to Create a database script that includes the SQL code for the following steps, aiming to execute each step using MYSQL Workbench to create and populate a new table called "recipe" in a database I already created called "fooddb". Said table was needed to have columns for "id" using auto incrementation, a title name for the recipe, One string of Instructions, an int for numOfServings, and an int for totalTime, in minutes.

So far, this is what I have created, using MySQL and documenting my progress... I have already created the database, fooddb, however, but I'll include that in my code I'm presenting here as well...


(I will use "insert into recipe values" for inserting many different elements, preferably 10 of them.)
My real concern is if any of this is right so far... Thank you for any advice offered here, otherwise.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question: why are you trying to create the tables in code? Usually the tables are created outside of the code -- the code just expects the tables to already be there.
 
Shakur Burton
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Question: why are you trying to create the tables in code? Usually the tables are created outside of the code -- the code just expects the tables to already be there.


I'm trying to get the tables recognized by the code I have created in Java, once this MySQL code has successfully compiled.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what's the problem? You can easily use database tools (I use DbVisualizer -- there are plenty to choose from) to make sure that the table haste been created correctly -- or event to create the tables.

Once created, referencing them from Java is just a matter of the proper JDBC code (or ORM if you are using one).
 
Shakur Burton
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've already created and successfully compiled this MySQL code in the MySQL database. But yeah, all that matters now is making sure it works alongside the Java code I posted in my second step to approaching this process. Very good advice, though. Thanks for that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic