Question

Regrettably, the company you work for did not hire a student from this class to design...

Regrettably, the company you work for did not hire a student from this class to design their database. You are given the following table definitions. You (hopefully) take one look and are amazed at how bad the design decisions are in these two tables alone. Amazingly the database seems to be working OK.

Propose a new way to implement these tables, list and explain the changes you make including why the old way was bad and your new change is better. (If you are not finding at least 5 things, look harder)

You should provide new CREATE statements and a written description of the original problems and how you fixed them. You are free to add additional tables, rename, remove or add columns. Points will be divided equally between having a new set of CREATE statements that are problem free and indentifying at least 5 problems in the original CREATE statements.

CREATE TABLE classes(
class_name CHAR(10) PRIMARY KEY,  
enrollment int -- Number of students currently enrolled in the class  
)engine=innodb;    

CREATE TABLE students(  
full_name CHAR(10) PRIMARY KEY,  
age INT,  
birthday VARCHAR(10),  
class1 CHAR(10),  
class2 CHAR(10),  
class3 CHAR(10),  
class4 CHAR(10),  
FOREIGN KEY (class1) REFERENCES classes(class_name) ON DELETE CASCADE,  
FOREIGN KEY (class2) REFERENCES classes(class_name) ON DELETE CASCADE,  
FOREIGN KEY (class3) REFERENCES classes(class_name) ON DELETE CASCADE  
)engine=innodb;
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hi,
the problem with the current approach is that there is a lot of redundancy if you see in the students table,
every student has 4 rows for each class they take which is redundant.
we can eliminate this by splitting the tables like this

CREATE TABLE classes(
class_name CHAR(10) PRIMARY KEY,  
enrollment int -- Number of students currently enrolled in the class  
)engine=innodb;   

-- classes table can remain same

CREATE TABLE ENROLLMENTS(
CLASS_NAME CHAR(10) PRIMARY KEY,
full_name CHAR(10),
FOREIGN KEY (full_name) REFERENCES students(full_name) ON DELETE CASCADE,
FOREIGN KEY (CLASS_NAME) REFERENCES classes(CLASS_NAME) ON DELETE CASCADE,  
)engine=innodb;

this is a new enrollments table that will store all the enrollments for a particular class along with the students name which is referenced as foregin key from the students table

CREATE TABLE students(  
full_name CHAR(10) PRIMARY KEY,  
age INT,  
birthday VARCHAR(10)
)engine=innodb;

And finally students table can exist as an independent table with only student related meta data in it.

Thumbs up if this was helpful, otherwise let me know in comments

Add a comment
Know the answer?
Add Answer to:
Regrettably, the company you work for did not hire a student from this class to design...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using SQL and the following info Question 3: Find the people who do not have Viper...

    Using SQL and the following info Question 3: Find the people who do not have Viper Certification but are still assigned to Viper class ship Find the fname, lname, and ship_instance_id for all people who do not have Viper certification but are assigned to at least one instance of a Viper class ship (this includes all variants of Viper class ships). Return a row for every ship/person combination. Order your results by fname in ascending order. Use the BSG database...

  • Using SQL and the following info Question 3: Find the people who do not have Viper...

    Using SQL and the following info Question 3: Find the people who do not have Viper Certification but are still assigned to Viper class ship Find the fname, lname, and ship_instance_id for all people who do not have Viper certification but are assigned to at least one instance of a Viper class ship (this includes all variants of Viper class ships). Return a row for every ship/person combination. Order your results by fname in ascending order. Use the BSG database...

  • Relational Database Design Theory, please answers ALL parts because they are related to each other, and I can't separate it into different questions. Please help! By looking at the PHLogger tab...

    Relational Database Design Theory, please answers ALL parts because they are related to each other, and I can't separate it into different questions. Please help! By looking at the PHLogger table: A. List all non-trivial functional dependencies. B. What is the highest normal form the PHLogger table is in currently? C. The external consulting experts at DBInstructor, Inc., have noticed that city and state of an address can be inferred by its postal code (zip code). What new functional dependencies...

  • Utilize the JigSaw SQL file below to create a Star Schema diagram. Remember, to create a...

    Utilize the JigSaw SQL file below to create a Star Schema diagram. Remember, to create a Star Schema from a normalized data model, you will need to denormalize the data model into fact and dimension tables. The diagram should contain all of the facts and dimension tables necessary to integrate the JigSaw operational database into a data warehouse. Write a brief paper describing the challenges you experienced in completing this assignment. -- CREATE DATABASE js; CREATE TABLE buy_methods ( buy_code...

  • I am trying to delete these tables from my data base and I keep getting: "mysql>...

    I am trying to delete these tables from my data base and I keep getting: "mysql> DROP TABLE Courses; ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails" I am using the command DROP TABLE Courses; Below is my sql file use sdev300; // Create a student table CREATE TABLE Students ( PSUsername varchar(30) primary key, FirstName varchar(30), LastName varchar(30), EMail varchar(60) ); CREATE TABLE Courses( CourseID int primary key, CourseDisc varchar(4), CourseNum varchar(4),...

  • Database Concepts! please help Consider the following create table statements: create table R (a integer primary...

    Database Concepts! please help Consider the following create table statements: create table R (a integer primary key); create tables (b integer primary key, c integer references R(a) on update cascade); Assume that these tables have the following data inserted: R: (1) and (2) S: (1,1) and (2, 1) What happens when we want to delete the record (1) from R? The corresponding record from S and T will be deleted due to the cascade option Only the record in Rwill...

  • SQL Query Question: I have a database with the tables below, data has also been aded...

    SQL Query Question: I have a database with the tables below, data has also been aded into these tables, I have 2 tasks: 1. Add a column to a relational table POSITIONS to store information about the total number of skills needed by each advertised position. A name of the column is up to you. Assume that no more than 9 skills are needed for each position. Next, use a single UPDATE statement to set the values in the new...

  • NEED HELP IN INSERT STATEMENTS FOR THE TABLES CAN YOU PLEASE ADD SOME INSERT STATEMENTS FOR...

    NEED HELP IN INSERT STATEMENTS FOR THE TABLES CAN YOU PLEASE ADD SOME INSERT STATEMENTS FOR A COMPANY SCHEMA SCRIPT. PLEASE ADN THANK YOU DROP TABLE dependent; DROP TABLE works_on; DROP TABLE project; DROP TABLE dept_locations; DROP TABLE department; DROP TABLE employee; CREATE TABLE employee ( fname varchar(15) not null, minit varchar(1), lname varchar(15) not null, ssn char(9), bdate date, address varchar(50), sex char, salary numeric(10,2), superssn char(9), dno numeric, primary key (ssn), foreign key (superssn) references employee(ssn) ); CREATE...

  • These question is for mysql, so I want know what is answer that is information for...

    These question is for mysql, so I want know what is answer that is information for source: DROP DATABASE IF EXISTS travel; CREATE DATABASE travel; USE travel; -- -- Table structure for table `equipment` -- DROP TABLE IF EXISTS `equipment`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `equipment` ( `EquipID` int(11) NOT NULL DEFAULT '0', `EquipmentName` varchar(50) NOT NULL DEFAULT '', `EquipmentDescription` varchar(100) NOT NULL DEFAULT '', `EquipmentCapacity` int(11) NOT NULL DEFAULT '0',...

  • Using the MySQL Workbench create a new database using your design specifications Add at least 10...

    Using the MySQL Workbench create a new database using your design specifications Add at least 10 records to your tables. Note: Certain tables may not require 10 records and that is ok as long as your main tables have 10 or more Create MySQL statements that will retrieve all records or rows from the tables in your database Create 10 MySQL statements that will retrieve specified records or rows from one table in your database Create 10 MySQL statements that...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT