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 Modifying Data with SQL Adding Data to a Database Adding a Row to a Table

karan Badhwar
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
karan Badhwar
Web Development Techdegree Graduate 18,135 Points

Do we create the Database Schema?

Do we create the database Schema or it is pre-installed and we just fill the values?

And if we have to create the Schema, then how do we do that?

Rosi A
Rosi A
8,892 Points

Hi Karan,

The database is already included in the Launch SQL Playground at the bottom right corner of the video. If you click on each table name, it will display all its contents and when you click on the stack icon (the icon that looks like a pile of stacked plates), you will be shown all the columns for that table.

karan Badhwar
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
karan Badhwar
Web Development Techdegree Graduate 18,135 Points

hi Rosi A , Thankyou for taking time and writing, but I was asking about when we create the database, as in sql playground it is already made up. so if we create the database then do we need to create the SCHEMA or it's gonna be done by the database?

1 Answer

Original poster probably got his answer, but this could be useful for other students: If you are creating database from scratch, and not building upon existing DB, then yes you will create Schema as well.

Schema is β€œblueprint” of a database which describes how the data may relate to other tables or other data models. However, the schema does not actually contain data. In order to enter data into database, you will first create a schema that will create rules upon which you will then enter data.

We could in simple terms say that database consist of multiple tables. You would create schema by creating each table in sql, defining their relations (foreign keys, parent/child relations and so on) For instance something like this:

CREATE DATABASE country CREATE TABLE city_list ( city_id varchar(5) NOT NULL, city_name varchar(45) default NULL, state_id varchar(5) default NULL, PRIMARY KEY (city_id), would create table city_list in database country. (this is a code for MySQL, that environment is great for creating DBs since it provides gui for schema representation)

A couple of things: Creating good schema is not exactly a 10min job, it is one of the more complex things, and for many uses you can and should build upon schema(s) you already have with modifications where needed. There are also schemas good samartians have put into public domain that can help you. But this is a topic for advanced users: If you are a beginner like me, don't panic, work on your SQL, and chances are you will breach the topic of database creation when you advance to budding developer.