Sunday, July 28, 2019

IT 330 Database Management Systems (Final Project)


IT 330 Database Management Systems
Final Project
Deadline: Sunday, July 28, 6pm. No late work accepted.

1.      Create a database for a school registration system.  The registration system should be able to hold information for the following entities:
a.      Students
b.      Courses
c.       Teachers
d.      Grades

At the minimum, the following queries should be answered:
- how many students are enrolled in a class?
-          How many courses are available on a Wednesday (or any given day)?
-          Who are the teachers teaching a particular course?
-          What is the average GPA for a course this semester?

2.      Create an ERD (entity-relationship diagram) that shows the relationships of all your tables.

3.      Normalize your tables.

4.      Create a one-page summary/documentation on how you were able to construct your database.  What are the (possible) pain points that still exist and how do you plan to address them in the future? 

5.      Submit your queries, database definitions, and diagram in either a Word file or (for the queries and results) a screenshot of your SQL developer commands and results.  Zip them all up into one zip file and upload to Blackboard.

ANSWER:


The ER diagram of the given scenario is given below. It consists of 3 entities connected via 2 relationships. Each entity has certain set of attribute and Primary key is mentioned as underlined attribute. Cardinality are shown




The data definition of the above ERD is given below. Five table are created from the given ERD. Tables are Student, Course, Teacher, Opt, Teaches.
DDL-
CREATE TABLE Student
(
StuID INT,
Name VARCHAR(20),
Address VARCHAR(100),
Phone VARCHAR(10),
DOB DATE,
PRIMARY KEY (StuID)
);
CREATE TABLE Course
(
CourseID INT,
Title VARCHAR(25),
Description VARCHAR(50),
Duration INT,
PRIMARY KEY (CourseID)
);
CREATE TABLE Teacher
(
TeacherID INT,
Name VARCHAR(30),
DOB DATE,
Qualification VARCHAR(20),
PRIMARY KEY (TeacherID)
);
CREATE TABLE Opt
(
StuID INT,
CourseID INT,
Year DATE,
Grade INT,
PRIMARY KEY (StuID, CourseID),
FOREIGN KEY (StuID) REFERENCES Student (StuID),
FOREIGN KEY (CourseID) REFERENCES Course (CourseID)
);
CREATE TABLE Teaches
(
TeacherID INT,
CourseID INT,
Day CHAR(10),
Date DATE,
Time DATE,
PRIMARY KEY (TeacherID, CourseID),
FOREIGN KEY (TeacherID) REFERENCES Teacher (TeacherID),
FOREIGN KEY (CourseID) REFERENCES Course (CourseID)
);

Wednesday, July 3, 2019

3- Write a program that reads every line in a text file, removes the first word from each line, and then writes the resulting lines to a new text file.

3- Write a program that reads every line in a text file, removes the first word from each line, and then writes the resulting lines to a new text file.
/**
 * @(#)buffer.java
 *
 * buffer application
 *
 * @author
 * @version 1.00 2019/7/3
 */
 import java.io.*;
 import java.util.Scanner;
 import javax.swing.JOptionPane;

public class buffer {
   
    public static void main(String[] args) {
   
    Scanner input = new Scanner(System.in);
   
    System.out.println("ENTER THE FILE TO READ");
    String infileName = input.nextLine().trim();
    // trim will remove spaces in the beginning and in the end
   
    System.out.println("Enter the file to write to");
    String outfileName = input.nextLine().trim();
   
    Scanner inputFile = null;
try{
inputFile = new Scanner (new File(infileName));
}catch (FileNotFoundException e){
System.out.println("Error the reading the file " + infileName);
System.exit(0);
}
   
    PrintWriter outputFile = null;
    try{
    outputFile = new PrintWriter(new File(outfileName));
    }catch (FileNotFoundException e){
    System.out.println("Error writing to the file " + outfileName);
    System.exit(0);
    }
    while(inputFile.hasNextLine()){
    String line = inputFile.nextLine();
    Scanner lineScanner = new Scanner(line);
   
    if(lineScanner.hasNext()){
    String word = lineScanner.next();
    int wordLocation = line.indexOf(word);
    String rest = line.substring(wordLocation+word.length());
    outputFile.println(rest);
    }
    else {
    outputFile.println(line);
    }
    }
    inputFile.close();
    outputFile.close();
   
    JOptionPane.showMessageDialog(null,"file processing completed! ", "JAVA to", JOptionPane.INFORMATION_MESSAGE);
    }
   
   
    }

1. Read the content of a text file and display the content 2. Write the content provided by the user into a text file.

1. Read the content of a text file and display the content
2. Write the content provided by the user into a text file.

/**
 * @(#)javaread.java
 *
 * javaread application
 *
 * @author 
 * @version 1.00 2019/7/1
 */
 import java.io.*;
 import java.util.Scanner;
 
 
public class javaread {
    
    public static void main(String[] args) {
     
    File myfile = new File ("C:\\Users\\Anonymous\\Desktop\\test.txt");
    try{
     BufferedReader br = new BufferedReader (new FileReader (myfile));
     String text;
     while ((text=br.readLine())!=null){
      System.out.println(text);
     }
     
    }catch(IOException e){
     System.out.println("File does not exit");
     
    }
    }


1. Read the content of a text file and display the content 2. Write the content provided by the user into a text file./**
 * @(#)javaread.java
 *
 * javaread application
 *
 * @author 
 * @version 1.00 2019/7/1
 */
 import java.io.*;
 import java.util.Scanner;
 
 
public class javaread {
    
    public static void main(String[] args) {
     
    File myfile = new File ("C:\\Users\\Anonymous\\Desktop\\test.txt");
    try{
     BufferedReader br = new BufferedReader (new FileReader (myfile));
     String text;
     while ((text=br.readLine())!=null){
      System.out.println(text);
     }
     
    }catch(IOException e){
     System.out.println("File does not exit");
     
    }
    }
}