CSCE 156/156H/RAIK 184H Assignment 4 - Project Phase III Database Design
CSCE 156/156H/RAIK 184H Assignment 4 - Project Phase III Database Design
Spring 2017
1 Introduction
In the previous phase of this project, you built an application framework that modeled
the given problem and processed data files to produce a report. In this phase, you will
design a data model that will support your application. You will do this by designing and
implementing an SQL database.
2 Database Design
You will design a (MySQL) database to store data that models the problem in the previous
phase. You will need to design your tables to support data related to the entities that you
identified and implemented in the previous phase as well as the relationship(s) between these
entities.
The exact details (including naming conventions, column/field types, and relational design)
are design decisions whose details are your responsibility. You must follow good database
design principles and best practices. You should make your database flexible enough that
records can be easily added/modified/removed without data integrity problems.
3 Requirements
You will implement your database using a DDL (document data language) file (which is a
plain text file containing SQL queries) and thoroughly test it using your MySQL account
1
Project Phase III CSCE 156/156H/RAIK 184H Spring 2017
on cse. Your DDL should contain queries to create your tables as well several queries to
thoroughly test your database design as described below.
While designing your database keep in mind the following:
What tables are necessary to support the application you designed in the previous
phase? In each table, what columns are necessary and what values should be allowed
and/or excluded?
How can data integrity be preserved? What primary, non-primary, and foreign keys
should be defined?
What are the relations between tables? What are the many-to-one or many-to-many
relations? What opportunities are there for further data integrity and normalization?
4 Artifacts
Your database design will be realized by writing SQL script files which will contain all the
necessary queries to create your database, insert some test data, and execute some queries
to modify and remove data.
You will hand in an SQL script (name it portfolioDB.sql ) that contains all of the neces-
sary SQL queries to create your database. Be sure that you do the following:
Use conditional drop table if exists statements to clear out old versions of tables
with the same name.
Do not include a use database statement in your final script file. We will be running
your DDL on our own database instance and will not have access to your database.
After creating your tables, include all necessary insert statements (along with any
nested select queries) to populate your database with some test data (this should be
the same data as in the test cases used in the previous phase if you wish).
2
Project Phase III CSCE 156/156H/RAIK 184H Spring 2017
1. A query to retrieve the major fields for every person
12. A query to find the total number of portfolios owned by each person
13. A query to find the total number of portfolios managed by each person
14. A query to find the total value of all stocks in each portfolio (hint: you can take an
aggregate of a mathematical expression)
15. A query to detect an invalid distribution of private investment assets (that is, a query
to add up the stake percentage of each such asset and return a list of investments
whose percentage exceeds 100%)
Clearly number these queries (using comments) in your SQL script and add any additional
testing queries at the end.
You will update and modify your Design Document draft that you started in the previ-
ous phase to include details on you database and data model design. An updated printed
hardcopy will be handed in 1 week prior to the assignment due date.
In the new section, make sure to given enough details so that a technically competent
individual would be able to reasonably reproduce an implementation of your design. Be sure
to address at least the following.
3
Project Phase III CSCE 156/156H/RAIK 184H Spring 2017
What are its primary and non-primary keys?
How are your tables related? What foreign key constraints did you use?
How does your database design support the application and problem statement re-
quirements?
When using MySQL, be sure to use InnoDB to ensure that foreign and primary key
constraints are respected
When using MySQL, use a case-sensitive character set to ensure correct data
Keys should be integers, not floats nor varchar ; though varchar columns may be
made unique if appropriate
Take care that you choose the correct data types for each of your columns
Leverage the power of SQL queries to aggregate datadont simply flatten the data
and process it as in the previous phase
Your data model should be generalit should reasonably handle and model situations
that may not necessarily be accounted for in your (or our) test cases