Painting Hire Business Case Study

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 14

PAINTING HIRE BUSINESS

A CASE STUDY BY: NIRMTI. KAMTEKAR, RAJITA. NAIR AND HARSHIL. SHAH

IDENTIFYING ENTITIES, ATTRIBUTES, RELATIONSHIPS, CARDINALITIES:

1) ENTITIES:
a) CUSTOMERS
b) ARTISTS
c) OWNERS
d) PAINTINGS

2) ATTRIBUTES:
a) FOR CUSTOMERS:
i) C_ID (PRIMARY KEY)
ii) C_NAME
iii) C_ADDRESS
iv) C_DESCRIPTION
v) C_NO (MOBILE NO.)
vi) C_CATEGORY (DERIVED)
vii) C_DISCOUNT (DERIVED)

b) FOR OWNERS:
i) O_ID (PRIMARY KEY)
ii) O_NAME
iii) O_ADDRESS
iv) O_NO (TEL. NO.)

c) FOR ARTISTS:
i) A_ID (PRIMARY KEY
ii) A_NAME
iii) A_COUNTRY
iv) A_YOB
v) A_YOD (OPTIONAL)
vi) A_AGE (DERIVED)
vii) A_NO (CELL NO.)
d) FOR PAINTINGS:
i) P_ID (PRIMARY KEY)
ii) P_TITLE
iii) P_THEME
iv) P_RETURN_STATUS
v) P_RETURNDATE
vi) P_ISSUEDATE
vii) P_DUEDATE (DERIVED)
viii) P_PRICE

3) RELATIONSHIPS:
a) OWNERS AND PAINTINGS: OWN
b) ARTISTS AND PAINTINGS: MAKE
c) CUSTOMERS AND PAINTINGS: RENT

4) CARDINALITIES:
a) OWNERS AND PAINTINGS – 1: MANY
b) ARTISTS AND PAINTINGS 1: MANY
c) CUSTOMERS AND PAINTINGS - 1: MANY
MAKING THE ER DIAGRAM USING ERDPLUS:

ER DIAGRAM SYMBOLS:
RECTANGLES - ENTITIES
OVALS - ENTITY ATTRIBUTES
DIAMONDS – RELATIONSHIPS
CONVERTING ER DIAGRAM TO RELATIONAL SCHEMA:

OUR RELATIONAL SCHEMA LOGIC:


IT CONTAINS THE PRIMARY KEYS OF ALL OTHER TABLES AS FOREIGN KEY IN THE PAINTINGS
TABLE BECAUSE THE PAINTINGS TABLE IS ON THE ‘MANY’ SIDE OF CARDINALITY WITH ALL
OTHER TABLES, SO PRIMARY KEY IS ON THE ‘1’ SIDE OF CARDINALITY AND FOREIGN KEY IS
ON THE MANY SIDE OF CARDINALITY.

DERIVED ATTRIBUTES ARE NOT STATED IN THE SCHEMA AS THEY GET THEIR VALUE FROM
OTHER TABLE SO THEY ARE NOT MENTIONED IN THE SCHEMA.
CREATING TABLES IN SQL BASED ON RELATIONAL SCHEMA:

1. OWNERS TABLE:

2. ARTIST TABLE:

3. CUSTOMERS TABLE:
4. PAINTINGS TABLE:
INSERTING VALUES IN THE CREATED TABLES:

1. FOR OWNERS TABLE:

2. FOR CUSTOMERS TABLE:

3. FOR ARTISTS TABLE:

4. FOR PAINTINGS TABLE:


OUTPUT OF TABLES AFTER INSERTING THE VALUES:

1. OWNERS TABLE

2. ARTISTS TABLE:

3. CUSTOMERS TABLE:
4. PAINTINGS TABLE:
GENERATING REPORTS BY JOINING TABLES AND ADDING DERIVED
COLUMNS (ATTRIBUTES):

1. RETURN TO OWNER REPORT

FOR BUILDING THIS REPORT WE JOINED OWNERS TABLE AND PAINTINGS TABLE ON
THE BASIS OF COMMON COLUMN O_ID WHICH IS A PRIMARY KEY FOR OWNES TABLE
AND FOREIGN KEY FOR PINTINGS TABLE.

WE SELECTED THE REQUIRED FIELDS FROM BOTH THE TABLES AND CREATED THE
REPORT AS MENTIONED ABOVE.

THIS REPORT SHOWS ON WHAT DATE WAS THE PAINTING RETURNED TO THE
OWNER BECAUSE THE PAINTING WAS NOT HIRED BY ANY CUSTOMER FOR 6
MONTHS. THE OWNER CAN RESUBMIT THE PAINTING AFTER 3 MONTHS OF THE
RETURN DATE.
2. ARTIST REPORT:

FOR GENERATING THIS TABLE, WE HAVE JOINED ARTISTS PAINTINGS TABLE WITH
ARTISTS TABLE.

TO GET THE DERIVED AGE COLUMN WE SUBTRACTED THE DOB (DATE OF BIRTH)
FROM DOD (DATE OF DEATH) AND THEN DIVIDE IT BY 365 TO GET AGE IN YEARS.
SINCE THE DIVISION WILL RESULT IN A DECIMAL NUMBER, WE APPLIED FLOOR TO
GET ONLY THE INTEGER PART OF THE VALUE.

FOR THE ARTISTS WHO ARE NO DEAD YET WE UPDATED THE TABLE USING THE
SAME LOGIC BY MAKING ONE SMALL CHANGE. WE REPLACED DOD (DATE OF DEATH)
BY CURRENT SYSTEM DATE WHICH WILL GIVE US THE AGE FOR ARTISTS WHOSE RAE
ALIVE. WE APPLIED A CONDITION WHERE AGE IS NULL BECAUSE WE ONLY NEED AGE
FOR THE ARTIST WHO ARE ALIVE.

AFTER DOING ALL THIS WE GET THE OUTPUT GIVEN AS FOLLOWS.


3. CUSTOMER RENTAL REPORT

FOR THIS REPORT WE HAVE TWO DERIVED ATTRIBUTES CATEGORY AND DISCOUNT.
WE HAVE DERIVED CATEGORY BASED ON TOTAL PRICE OF PAINTINGS RENTED BY
CUSTOMERS. FOR THIS WE CREATED A SUB TABLE ‘Z’ INCLUDING ONLY CUSTOMER
NAME AND SUM OF PAINTING PRICE AND NAMED IT AS TOTAL PRICE THEN WE
GROUPED IT BY CUSTOMER NAME TO GET TOTAL PICE OF ALL PAINTING PURCHASED
BY A CUSTOMER.

THEN WE ADDED A CATEGORY COLUMN TO THE TABLE USING ALTER COMMAND.


THEREAFTER WE UPDATED THE COLUMN USING UPDATE COMMAND MULTIPLE
TIMES USING MULTIPLE WHERE CONDITIONS WHICH REPRSENTED THE CUSTOMER
CATEGORY.
IF TOTAL PRICE OF CUSTOMER WAS BELOW 200000 THEN ‘B’ WAS GIVEN TO THE
CUSTOMER REPRESENTING BRONZE CATEGORY.
IF TOTAL PRICE OF CUSTOMER WAS ABOVE 200000 AND BELOW 250000 THEN ‘S’
WAS GIVEN TO THE CUSTOMER REPRESENTING SILVER CATEGORY.
IF TOTAL PRICE OF CUSTOMER WAS ABOVE 250000 AND BELOW 300000 THEN ‘G’
WAS GIVEN TO THE CUSTOMER REPRESENTING GOLD CATEGORY.
IF TOTAL PRICE OF CUSTOMER WAS ABOVE 300000 THEN ‘P’ WAS GIVEN TO THE
CUSTOMER REPRESENTING PLATINUM CATEGORY.
SIMILARLY, WE CREATED A NEW COLUMN OF DISCOUNT WHICH IS BASED ON
CUSTOMER CATEGORY. IF THE CATEGORY IS BRONZE THEN NO DISCOUNT IS
OFFERED, IF THE CUSTOMER IS SILVER, 5% DISCOUNT IS GIVEN. A GOLD CUSTOMER
IS GIVEN 10% DISCOUNT AND PLATINUM CUSTOMER GETS 15% DISCOUNT.

THE FINAL TABLE AFTER ALL THIS IS FOLLOWING:


ALAS, AFTER ALL THIS, WE JOIN THIS TABLE ‘Z’ WITH CUSTOMERS TABLE AND ALSO
‘PAINTINGS’ TABLE WITH CUSTOMERS TABLE. WE SELECT ALL THE ROWS REQUIRED
AND FINALLY FORM THE REPORT REQUIRED.

THANK YOU

You might also like