You've learned a lot of SQL and now you're going to put it all together by designing a whole database. The goal is to create a set of well-constructed tables and relationships that could actually be used by the application you've been using for all your data modeling exercises.
By trying to fit your app's data into a spreadsheet, you learned how to separate all the unique entities that your app cares about. The process of normalizing the data to fit into columns helped you discover all of the attributes for each entity. Then you mapped out the relationships between those entities in a database diagram, which gave you a better idea of how to structure your tables and add key columns.
Open your code editor and make a new SQL file. Save it with your name, like last_first.sql
. At the top of the file, write the name of the application using SQL comments. This file will contain all the SQL queries to create the tables/columns/constraints/relationships and insert all of your data.
CREATE TABLE
statements for all of your entity types.
INSERT INTO
statements to fill your tables with some data.
To grade your lab, I'm going to create a new database and then run your file all at once. There shouldn't be a single error. If you've designed your table well, I'll be able to tell at a glance what data it contains and how entities relate to each other.
You should do the same thing to make sure it all works. For example, say someone is working the school portal. I'll create a new database called portal
and then run their queries with the following command:
$ psql portal -f last_first.sql
DROP
or DELETE
statements. It might take a few attempts to get everything right.Good luck!