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

Sahar Nasiri
Sahar Nasiri
7,454 Points

How to build my own local Database Scheme?

I use teamtreehouse workspace to learn SQL, I want to build my own database scheme on my own computer, how can I do this? What should I install?

4 Answers

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

Hi Sahir,

To start with you can build a scheme by hand by saving a text file as a .sql file or a .db file.

You can then use a program like MS Workbench to generate the data.

Also if you want to build a database as a backend for a dynamic web application you can import a .sql file into phpmyadmin which will, again create a database and read the data.

Good luck! :-)

Sahar Nasiri
Sahar Nasiri
7,454 Points

Thanks,

But I cannot build a table or some tables as a scheme in a text file! Can I? I think you meant I can write my queries in a text file, right? Where can I build tables as Database Scheme? Excel? Or this MS Workbench?

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 91,253 Points

Building tables and data is one of the CRUD operations of building databases, specifically the C for Create.

So you can build data, tables and query that data in the same file! :-)

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 91,253 Points

Hi Sahir,

Maybe I'm misunderstanding what you're trying to ask.

Let me try to explain what I think you're wanting. :-)

In the first case you will write SQL in a text file to generate the Schema. Now, it's in this schema that lays out the bluprint of the database and where you'll populate data in your database. This is where you'll write code that creates data that can then be queried.

It is also here that you write the code that will eventually create the data. This happens when you import the SQL file into a program that can read the SQL and build the actual table with data that you can then query.

You can query data in the same file but you can do this from external sources to like an SQL query in a PHP file where you'll connect to a given databae and run a query on it to return results.

So to summarise.

  • You write SQL code that tells a computer or a database server what to do with data.
  • Import it into a program (e.g. Workbench or phpmyadmin)
  • Visualise data or run queries on it through those programs.
Sahar Nasiri
Sahar Nasiri
7,454 Points

Alexander Nikiforov, thank you very much. This is exactly what I was looking for, but I did not know that teamtreehouse has this course ;).

Sahar Nasiri
Sahar Nasiri
7,454 Points

Jonathan Grieve, how can I build a table in a text file? Does text file have a table option? I did not know that!

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 91,253 Points

Hi Sahir,

Maybe I'm misunderstanding what you're trying to ask.

Let me try to explain what I think you're wanting. :-)

In the first case you will write SQL in a text file to generate the Schema. Now, it's in this schema that lays out the bluprint of the database and where you'll populate data in your database. This is where you'll write code that creates data that can then be queried.

It is also here that you write the code that will eventually create the data. This happens when you import the SQL file into a program that can read the SQL and build the actual table with data that you can then query.

You can query data in the same file but you can do this from external sources to like an SQL query in a PHP file where you'll connect to a given databae and run a query on it to return results.

So to summarise.

  • You write SQL code that tells a computer or a database server what to do with data.
  • Import it into a program (e.g. Workbench or phpmyadmin)
  • Visualise data or run queries on it through those programs.