Learning Goals
By the end of this section you will:
The CREATE TABLE statement is used to create a new table in a database.
Go to the W3schools Tutorial on the CREATE TABLE Statement and complete their exercises.
We will use DB Broswer to create our databases. Watch the videos below to see how.
Β
CREATE TABLE orderΒΆ
When creating a relational database containing multiple tables, you need to be findful of order in which theyβre created. If a table contains a foreign key, this foreign key needs to be able point to the table of where it is the primary key, ie. the one side of the one-to-many relationship. So the table containing the primary key needs to be create first.
Letβs look at the student subject database from the ERD / RS section:

We can observe:
Both the Teacher and the Student tables have no foreign keys, so they can be created straight away.
The Subject table cannot be created until the Teacher table is created
The Enrolment table cannot be create until both the Subject table and the Student table is created.
CREATE TABLE Activities
Create dartabases for the Relational schemas you created in the ERD and RS section
Activity 1

Activity 2

Activity 3

Activity 4
