Painting Hire Business Case Study
Painting Hire Business Case Study
Painting Hire Business Case Study
A CASE STUDY BY: NIRMTI. KAMTEKAR, RAJITA. NAIR AND HARSHIL. SHAH
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:
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. OWNERS TABLE
2. ARTISTS TABLE:
3. CUSTOMERS TABLE:
4. PAINTINGS TABLE:
GENERATING REPORTS BY JOINING TABLES AND ADDING DERIVED
COLUMNS (ATTRIBUTES):
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.
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.
THANK YOU