First, we should figure out what tables we need. In the table above, note the following:
We do not want to over-complicate things by creating too many tables, but we also do not want a lot of wasted space in each table. We will strike this balance as follows:
We will need to setup some relationships for these tables, namely that the GitHub and courses tables refer to professors that already exist in the faculty table.
We will create a faculty_names
table with 1 row per professor that stores:
usfid
), which must be unique, may not be null, and can be used as the primary key for this table and the foreign key for other tables.first
, middle
, and last
names in separate columns. The middle
initial may be null. None of these columns need to be unique. For example, more than one person has the first name David
in the department.Exercise: See if you can create a faculty_names
table that will match the following:
Field | Type | Null | Key | Default | Extra |
---|---|---|---|---|---|
usfid | char(20) | NO | PRI | NULL | |
first | varchar(20) | NO | NULL | ||
middle | char(1) | YES | NULL | ||
last | varchar(20) | NO | NULL |
Once you have the table created, you can insert values as follows: