You are on page 1of 6

MIS Spring 16 - Homework 3

Assigned: March 6

Instructor: McGinity
Due: March 11

For each of the below scenarios, create an ERD and DB design outline, as indicated in class.
This assignment has 3 steps:
1) Use the LucidChart ERD Template 3 to make your entity-relationship diagram;
2) Share your ERD with me (mcginity@scarletmail) via LucidChart;
3) Use the LucidChart Google Doc addon to insert your ER Diagrams into this file.
*Please be sure to also include your outlines as text in this document.

Q1. Corporate Ownership and Boards


A federal regulatory agency is trying to track the relationships between a large number of companies and
individuals. For the purposes of this exercise, assume that the agency is interested only in the present state of
these relationships, and not in how they may have changed over time.
For each individual, you want to store the social security number, first name, last name, middle name/initial, date of
birth, address, city, state, zip code, email address, and phone number. Assume the agency wants to include a zip
code table in the database. For each company, you want to store a tax ID number, name, mailing address, city,
state, and zip code. Assume that all individual and company addresses are within the USA.
The agency wants to understand the ownership relationships between the individuals and companies. The system
should record which companies each individual owns stock in, and how many shares are involved. Furthermore,
some of the companies hold stock in other companies. You want to record each such situation, including the
number of shares held.
In addition to stock ownership, an individual may also be related to a company by membership on its board of
directors. You want the system to record all such board memberships.
Design a database to hold all this information. Use the LucidChart ERD Template 3 to make an entity-relationship
diagram, share your ERD with me (mcginity@scarletmail), and insert your ERD into this file using the addon.

Q1. Solution: Corporate Ownership and Boards

CREATE TABLE
CREATE TABLE

Zipcode( zip int PRIMARY KEY, City CHAR(100), State CHAR(2) );


Company( tax_id int PRIMARY KEY,
name CHAR(30),
address CHAR(50),
zip int CONSTRAINT fk_zip REFERENCES Zipcode(zip),
);
CREATE TABLE Individual( ssn int PRIMARY KEY,
first_name CHAR(20),
middle_name CHAR(20),
last_name CHAR(30),
birth_date DATETIME,
address CHAR(50),
zip int CONSTRAINT fk_zip REFERENCES Zipcode(Zip),
phone INTEGER,
email CHAR(50),
);
CREATE TABLE IsBoardMember( ssn int CONSTRAINT fk_indv REFERENCES Individual(ssn),
tax_id int CONSTRAINT fk_comp REFERENCES Company(tax_id)
PRIMARY KEY (ssn, tax_id)

);
CREATE TABLE OwnsShares( ssn int CONSTRAINT fk_indv REFERENCES Individual(ssn),
tax_id int CONSTRAINT fk_comp REFERENCES Company(tax_id)
num_shares DOUBLE,
PRIMARY KEY (ssn, tax_id)
);
CREATE TABLE COwnsShares( owner_tax_id int CONSTRAINT fk_compA REFERENCES Company(tax_id),
tax_id int CONSTRAINT fk_compB REFERENCES Company(tax_id)
num_shares DOUBLE,
PRIMARY KEY (owner_tax_id, tax_id)
);

Q2. Sustainability Taskforce

You have signed on as a member of Sustainability Taskforce, which sponsors ecologically-oriented community
projects of various kinds (such as building and distributing composters or constructing energy-efficient low-income
housing). You have volunteered to start building a relational database to replace the hodgepodge of spreadsheets
currently being used to track membership and projects. Assume you have access to zip code table, and plan to
include it in the database.
First, you want to keep track of all the taskforce's members. For each member, you want to store the following
information: first name, middle name, last name, date of birth, address information (street address, city, state, and
zip code), phone number, email address, and date of joining the organization. Furthermore, most members have a
mentor, who is another member of the taskforce.
For each project, you want to store a name, worksite address (street address, city, state, and zip code), description,
date started, and date ended (blank if the project is still ongoing). Furthermore, you want the database to remember
which members are involved in each project: a project can involve as few as one member and in some cases as
many as 25.
Each project has at least one designated project leader; usually there is just one leader per project, but for some
larger projects there may be more. You need to track the leaders for each project. Additionally, you want to feature
the project leaders (less than %5 of all members) on the website with a photo and short bio. The bio will be about
one paragraph, requiring the Access Memo data type, and the photo will be an Attachment data type.
Design a database to hold all this information. Use the LucidChart ERD Template 3 to make an entity-relationship
diagram, share your ERD with me (mcginity@scarletmail), and insert your ERD into this file using the addon.

Q2. Solution: Sustainability Taskforce

CREATE TABLE
CREATE TABLE

Zipcode( zip int PRIMARY KEY, City CHAR(100), State CHAR(2) );


Project( project_id int PRIMARY KEY,
projet_name CHAR(30),
address CHAR(50),
zip int CONSTRAINT fk_zip REFERENCES Zipcode(Zip),
description CHAR(255),
date_started DATETIME,
date_ended DATETIME) ;
CREATE TABLE Member( member_id int PRIMARY KEY,
first_name CHAR(20),
middle_name CHAR(20),
last_name CHAR(30),
birth_date DATETIME,
address CHAR(50),
zip int CONSTRAINT fk_zip REFERENCES Zipcode(Zip),
phone INTEGER,
email CHAR(50),
date_joined DATETIME,
mentor_id int CONSTRAINT fk_mentor REFERENCES Member(MemberID)
);

CREATE TABLE Leader(leader_id int PRIMARY KEY CONSTRAINT child_leader REFERENCES


Member(member_id), photo *cannot be done with SQL DDL*, biography *cannot be done with SQL DDL* );
CREATE TABLE Involved( member_id int CONSTRAINT fk_involvedmember REFERENCES Member(member_id),
project_id int CONSTRAINT fk_involvedproject REFERENCES Project(project_id),
leader YESNO,
PRIMARY KEY(member_id, project_id)
);

You might also like