jash mehta ist 659 final project report

23
1 INDOOR MAP PROJECT (ROOMS): CARNEGIE LIBRARY JASH MEHTA IST 659 FINAL PROJECT REPORT

Upload: jash-mehta

Post on 21-Feb-2017

82 views

Category:

Data & Analytics


3 download

TRANSCRIPT

1

INDOOR MAP PROJECT (ROOMS): CARNEGIE LIBRARY

JASH MEHTA

IST 659 FINAL PROJECT REPORT

2

Table of Contents

Project Summary ……………………………………………………..3

Tables and Attributes ……………………………………………………..5

Entity Relationship Diagram ……………………………………………………..7

Business Rules …………………………………………………….10

Database Infrastructure …………………………………………………….10

SQL Scripts for Creating and Inserting Sample Data

…………………………………………………….10

Major Data Questions …………………………………………………….16

Forms and Reports(Interfaces)

…………………………………………………….18

Triggers …………………………………………………….22

3

Summary: The resources of the Carnegie include rooms that a SU user could use at the library.

For instance, there are rooms like Offices, Stack Area, Classrooms, Computer Lab,

Computer Cluster.

All rooms have resources such as chairs & table and technology. Classrooms can be

booked by faculty.

Therefore if faculty wants to know which rooms has sufficient capacity then the

faculty can log into the app to find out about the room he/she wants to book.

The resources can be located in a room or outside a room. These resources are

classified based on resource types and also based on the different levels they are

located on.

Supposedly, other resources include dust bins, elevators, exits and entrances in the

Carnegie Library. User (student or faculty) can log into the SU Indoor Map to find out

these other resources.

The scope of my project is limited to identify the rooms and other resources and

their locations at Carnegie so that these details can be fetched by the SU Indoor

Outdoor app.

Major Data Question

The App will be used by two kind of users

SU students and faculty

Database administrator

Why would SU students and faculty query the database?

Faculty has the privilege to book rooms in Carnegie Library therefore if any professor

would like to know information regarding the rooms then the database would be

queried

4

Students would like to locate the rooms and respective events in the room. Also,

students & faculty would like to locate the other resources such as drinking fountain,

washrooms, entrance, exits and elevators.

Why would database administrator query the database?

The database administrator would query the database in the event of finding out the

current status of any room or event. Administrator would like to query in order to

update the database. For example, if the semester changes and the events in the

room needs to be changed then it responsibility of the administrator to change it.

Also, if there is any reconstruction or reordering of any of the rooms then the

administrator must make changes in the database.

5

Tables & Attributes Database object & Attributes Description User User of the SU indoor Map

PK SUID UserFirstName UserLastName Age Email Gender UserType

Primary Key: Identifies the user uniquely User’s First Name User’s Last Name Age of the user SuEmail of the user Gender of the user Faculty or Student

Rooms Stores Information about all the rooms

PK RoomNumber Department Floor RoomType Timings No_Of_Projectors No_Of_Screens NoOfChairs NoOfTables RoomAccess Room Type

PK: Identifies the room uniquely Under which department does the room come On which floor is the room located Office, Classroom, Computer Lab etc Opening and Closing Hours Number of resources in the rooms: Number of projectors, screens, chairs and tables Private or Public Discriminator: Classroom(CR), ComputerLab(CL), Office (O)

Other Resources

Stores other resources such as washrooms, bins, drinking fountain, elevators, entrance and exits

PK ResourceID FK SUID ResourceName Floor

Unique ID for resources to identify resources SUID taken as foreign key from the User Table Vending Machine, Washroom, Dustbin Floor on which the resource is located

UserRoom Bridge table between user and Rooms as it is many to many relationship between user and rooms

6

PK URid FK SUID FK RoomNumber Start Time End Time Date

Uniquely identifies the booking for the user and room Foreign key from user table Foreign key from Rooms table Start time the room booked End time of the room booked The date for which room is booked

Computer Lab Stores Information about all the computers in the room

PK,FK RoomNumber NoOfComputers NameOfPrinter TypeOfPrinter NameOfScanner TypeOfScanner

Primary key as well as foreign key to implement disjoint logic Number of Computers Name of the printer Brand/Company of the printer Name of the Scanner Brand/Company of the scanner

Classroom Stores information regarding the classrooms

PK, FK RoomNumber FK ClassID

Primary key as well as foreign key to implement disjoint logic

Class Stores information regarding the event occurring in the classroom

PK ClassID URid School Year Semester

Uniquely identifies the class which is being conducted in the classroom URid as foreign key from UserRoom bridge table The school year: For example 2016, 2017 Fall, Spring, Summer

Office Stores information regarding the person and the contact in the office

PK, FK RoomNumber PersonIncharge_FirstName PersonIncharge_LastName ContactNumber

Primary key as well as foreign key to implement disjoint logic First Name of the person Last Name of the person Phone number of the office

7

Entity Relationship Diagram

Visio

8

SQL

9

Access

10

Business Rules Many users can use/search for many rooms

A user of the App may search for one or many other resources

The rooms are complete disjoint entities. A room can be a computer lab, computer cluster,

classroom, office or a stack area

One classroom can have one class at a given time

Database Infrastructure: The database infrastructure is based on client-server model. SQL server is used as the database engine

and access is used as the interface design tool. Data is inserted, deleted, updated and queried from the

SQL server database with the help of forms on Access. Useful data stored on SQL database can also be

viewed with the help of reports generated through access.

SQL Scripts for Creating and Inserting Sample Data: NOTE: I am giving only one insert script for each table rest of the data was inserted by access forms

CREATE TABLE CUSer ( SUID CHAR(10)NOT NULL, UserFirstName Varchar(30), UserLastName Varchar(30), UserAge INTEGER , UserEmail varchar(20), UserGender Varchar(2), User_Type Varchar(30), CONSTRAINT SUID_PK PRIMARY KEY (SUID) ); INSERT INTO CUSer Values ('12345678','Sachin','Tendulkar','44','[email protected]','M','Faculty')

11

CREATE TABLE CROOMS ( RoomNumber Char(5) NOT NULL, Department varchar(30), CFLoor char(2) , Timings varchar(20) , No_Of_Projectors INTEGER, No_Of_Screens INTEGER, No_Of_Chairs INTEGER, No_Of_Tables INTEGER, Capacity INTEGER, RoomAccess Varchar(30), RoomType Varchar(30) NOT NULL CHECK (RoomType In ('CL','CR','O')), CONSTRAINT RoomNumber_PK PRIMARY KEY (RoomNumber) ); INSERT INTO CROOMS Values ('C108','ABC','2','8 am - 5pm',1,1,20,3,23,'public','CR')

CREATE TABLE Resources ( ResourceID Varchar(30) NOT NULL,

12

SUID CHAR(10) NOT NULL, ResourceName Varchar(30), CFLoor char(2), CONSTRAINT ResourceID_PK PRIMARY KEY (ResourceID), CONSTRAINT Resources_FK_SUID FOREIGN KEY (SUID) References CUSer(SUID) ); INSERT INTO Resources Values ('VM103','12345678','Vending Machine','1')

CREATE TABLE UserRoom ( URid Varchar(15) NOT NULL, SUID CHAR(10) NOT NULL, RoomNumber Char(5) NOT NULL, URSTime Varchar(30), URETime Varchar (30), URDATE Varchar (30), CONSTRAINT URid_PK PRIMARY KEY (URid), CONSTRAINT UserRoom_FK_SUID FOREIGN KEY (SUID) References CUser(SUID), CONSTRAINT UserRoom_FK_RoomNumber FOREIGN KEY (RoomNumber) References CROOMS(RoomNumber) ); INSERT INTO UserRoom Values ('15','10001','c201','8 am', '9 am', 'May')

13

Create table Class ( classID Varchar(30) NOT NULL, URid Varchar(15) NOT NULL, SchoolYear Varchar(30), Semester Varchar(30), CONSTRAINT Class_PK PRIMARY KEY (classID), CONSTRAINT Class_FK_URid FOREIGN KEY (URid) References UserRoom(URid) ); INSERT INTO Class Values ('c15','15','2016','Spring')

CREATE TABLE ClassRoom ( RoomNumber Char(5)NOT NULL, classID Varchar(30) NOT NULL,

14

CONSTRAINT RoomNumber_PK2 PRIMARY KEY (RoomNumber), CONSTRAINT ClassRoom_FK_RoomNumber FOREIGN KEY (RoomNumber) References CROOMS(RoomNumber), CONSTRAINT ClassRoom_FK_classID FOREIGN KEY (classID) References Class(classID), ); INSERT INTO ClassRoom Values ('c201','c15')

CREATE TABLE Office ( RoomNumber Char(5)NOT NULL, PersonInCharge_FNAME Varchar(30) , PersonInCharge_LNAME Varchar(30) , PhoneNumber Varchar(30), CONSTRAINT RoomNumber_PK3 PRIMARY KEY (RoomNumber), CONSTRAINT Office_FK_RoomNumber FOREIGN KEY (RoomNumber) References CROOMS(RoomNumber), );

15

CREATE TABLE ComputerLab ( RoomNumber Char(5) NOT NULL, No_Of_Computer INTEGER, No_Of_Printer INTEGER, Name_Of_Printer varchar(30), No_Of_scanner INTEGER, Name_of_scanner varchar(30), CONSTRAINT RoomNumber_PK1 PRIMARY KEY (RoomNumber), CONSTRAINT ComputerLab_FK_RoomNumber FOREIGN KEY (RoomNumber) References CROOMS(RoomNumber) ); INSERT INTO ComputerLab Values ('Cl102',45,2,'HP Laser Jet', 45, 'Hp')

16

Major Data Questions

-User can know how many classrooms, offices, computer lab are on each floor SELECT Count(CROOMS.RoomNumber) AS CountOfRoomNumber, CROOMS.RoomType, CROOMS.RoomAccess, CROOMS.CFLoor FROM CROOMS GROUP BY CROOMS.RoomType, CROOMS.RoomAccess, CROOMS.CFLoor;

17

- Admin can create report to generate semesterwise classes in Carnegie Library SELECT CUSer.UserFirstName, CUSer.UserLastName, ClassRoom.RoomNumber, Class.Semester, Count(Class.classID) AS CountOfclassID FROM CUSer INNER JOIN (UserRoom INNER JOIN (Class INNER JOIN ClassRoom ON Class.classID = ClassRoom.classID) ON UserRoom.URid = Class.URid) ON CUSer.SUID = UserRoom.SUID GROUP BY CUSer.UserFirstName, CUSer.UserLastName, ClassRoom.RoomNumber, Class.Semester HAVING (((Class.Semester)='Fall')); SELECT CUSer.UserFirstName, CUSer.UserLastName, ClassRoom.RoomNumber, Class.Semester, Count(Class.classID) AS CountOfclassID FROM CUSer INNER JOIN (UserRoom INNER JOIN (Class INNER JOIN ClassRoom ON Class.classID = ClassRoom.classID) ON UserRoom.URid = Class.URid) ON CUSer.SUID = UserRoom.SUID GROUP BY CUSer.UserFirstName, CUSer.UserLastName, ClassRoom.RoomNumber, Class.Semester HAVING (((Class.Semester)='Spring'));

18

Interfaces

Sub form with combo box Form to fill data into Class, ClassRoom, UserRoom tables

19

Form to fill data into Crooms and Computer Lab tables

Form to fill data into User Table

20

Reports for major data questions: - Admin can create report to generate semester wise classes in Carnegie Library

21

-User can know how many classrooms, offices, computer lab are on each floor

22

Trigger Before Trigger

As you can see C203 has 20 chairs and 20 tables and capacity is 20.

What my trigger does is it updates capacity = chairs + tables

create trigger updateCRooms ON CROOMS FOR UPDATE AS BEGIN UPDATE CROOMS SET Capacity = a.Capacity FROM (select c.RoomNumber AS rnum,(c.no_of_tables +i.No_Of_Chairs) As 'Capacity' FROM CROOMS c Inner join inserted i on i.RoomNumber = c.RoomNumber )a where Crooms.RoomNumber = a.rnum End;

update CROOMS set No_Of_Chairs= 20 where RoomNumber='C203'

23

After Trigger:

You can see the capacity column of C203 has been updated