Homework 11: Project Milestone: Database Schema Implementation
For this project milestone, you should implement the database schema for your web application.
Of course, you should work with your project team.
Instructions
You can implement the database schema however you think best. For example, if you are using Django, you would simply edit the models.py
file for your application, generate migrations, and then run those migrations. If you are not using Django, you could simply write SQL commands in a .sql
text file, and load that .sql
file into the database.
You should implement:
- Primary keys
- Foreign keys
- Uniqueness constraints
Note: You might be tempted to simply create the database schema by running SQL commands interactively in psql
. It’s okay to do this, but if you do you must remember to copy-paste your SQL commands into a .sql
file, then to test loading that .sql
file. Otherwise, you might not have a record of the SQL commands needed to initialize the database, which would make it difficult to set up your web app on a new device.
Submit
Submit:
- The code you used to create your database schema (e.g.,
models.py
ormy_app.sql
) - Details of each database table, in the format given by running
\d TABLE_NAME
inpsql
. For example:
django_data=# \d minifacebook_profile
Table "public.minifacebook_profile"
Column | Type | Collation | Nullable | Default
------------+------------------------+-----------+----------+---------
id | uuid | | not null |
first_name | character varying(100) | | not null |
last_name | character varying(100) | | not null |
email | character varying(254) | | not null |
activities | text | | not null |
Indexes:
"minifacebook_profile_pkey" PRIMARY KEY, btree (id)
Referenced by:
TABLE "minifacebook_poke" CONSTRAINT "minifacebook_poke_pokee_id_a9e58507_fk_minifacebook_profile_id" FOREIGN KEY (pokee_id) REFERENCES minifacebook_profile(id) DEFERRABLE INITIALLY DEFERRED
TABLE "minifacebook_poke" CONSTRAINT "minifacebook_poke_poker_id_c98ef308_fk_minifacebook_profile_id" FOREIGN KEY (poker_id) REFERENCES minifacebook_profile(id) DEFERRABLE INITIALLY DEFERRED
TABLE "minifacebook_status" CONSTRAINT "minifacebook_status_profile_id_dfb04e9b_fk_minifaceb" FOREIGN KEY (profile_id) REFERENCES minifacebook_profile(id) DEFERRABLE INITIALLY DEFERRED
Only one team member should upload the assignment. Your submission will be graded for correctness and completeness.