Education and Research Department Project Specification for Oracle Jul 2005 Document No. Authorized By Ver. Revision Signature / Date ER/CORP/CRS/DB25/ 006 Dr. Ravindra M.P. Ver. 1.0 Jul 2005 COMPANY CONFIDENTIAL © Infosys Technologies Limited Document Revision History Document Revision History Ver. Revision Date Author(s) Reviewer(s) Description 1.00 Jul-2005 Sureesh Anubhav Nagendra Setty Rajagopalan P Initial write ER/CORP/CRS/DB25/006 Version No. 1.0 i © Infosys Technologies Limited Table of Contents Table of Contents EDUCATION AND RESEARCH DEPARTMENT 1 PROJECT SPECIFICATION FOR ORACLE 1 1 BACKGROUND 1 2 BUSINESS REQUIREMENTS 1 ER/CORP/CRS/DB25/006 Version No. 1.0 i Infosys Project Specification for Oracle 1 Background This document contains the high level design of the project that has to be executed in order to complete the course Oracle. This project is the Database creation part of Automation of Infy Bank. The database will be used for other modules. 2 Business Requirements The following are the business requirements for this project Sl Requirement 1 Table Creation 2 Sequence Creation 3 Inserting Sample Data (SQL Script) 4 Query Generation 5 Stored Procedure Creation 2.1 List of Files supplied Sl File Description 1 Data.xls Sample Data 2.2 Best Practices a) Chose the most appropriate data type while creating the table. b) Create appropriate constraints wherever applicable while creating the table. c) Use SQL loader to import data from some other data source wherever possible. d) Always use anchored declaration while creating stored procedures and functions. e) Carefully select the control structures. f) Wherever applicable use bind variables. g) Create appropriate triggers to implement business logic. h) Always store the scripts in the text files. i) Declare appropriate mode for variables in stored procedures and functions. j) The input and output parameters datatype should be SQL compatible while creating stored functions. k) Please follow day5 (LC) / day4 (SC) ppts for further information on best practices. ER/CORP/CRS/DB25/006 Version No. 1.0 Page 1 Infosys Project Specification for Oracle l) Always handle errors using exception handling construct wherever applicable. 2.3 Table Creation This module is used to create tables for storing data. To get more information about field size and data type, refer the C project specification. a) Login (This table stores the authentication information) UserID Password Role (M, C, S) Manager, Customer, Staff b) Customer (This table stores the customer information) CustomerID UserID (For authentication purpose) Name Gender (M, F) DateOfBirth Address City State Pin Telephone Fax Email c) Employee (This table stores the Employee information) EmployeeID (Auto, Use a sequence) UserID (For authentication purpose) Name Gender (M, F) DateOfJoin Email Job d) Account (This table stores the Account Information. One customer can have more than one account) AccountNo CustomerID AccountType ER/CORP/CRS/DB25/006 Version No. 1.0 Page 2 Infosys Project Specification for Oracle DateOfOpening CurrentAmount Status (C, F) Status indicating whether the account is closed or functional e) Transaction (This table stores the details of each transaction) TransactionID (Auto, Use a sequence) AccountNo DateOfTransaction Amount TransactionType (D, W) Deposit, Withdraw Description f) Locker (This table stores the locker information) LockerNumber CustomerID DateOfOpening g) LockerOperation LockerNumber DateOfOperation InTime OutTime 2.4 Sequence Creation The sequence is used to generate unique numbers for the following fields a) TransactionID b) EmployeeID 2.5 Data Insertion Insert the sample data into the tables. You are free to include more sample records. 2.6 Queries Write the following queries. a) Query to display AccountNo, CustomerID and Name of all the valid Account Holders. ER/CORP/CRS/DB25/006 Version No. 1.0 Page 3 Infosys Project Specification for Oracle b) Query to display AccountNo, CustomerID and Name of all the account holders whose accounts have been deleted. c) Query to display the last 10 transaction for a particular account. 2.7 Stored Procedures Create the following stored procedures a) Create a Stored Procedure/function for Authentication. The SP should accept UserID and Password and return an integer as explained below i) 1, if the Role is Manager. ii) 2, if the Role is Staff. iii) 3, if the Role is Customer and her account is functioning. iv) 4, if the Role is Customer and her account is deleted. v) 5, if the UserD/Password is invalid. vi) 0, if the SP fails. b) Create a Stored Procedure/Function to check whether an AccountNo is existing The SP should accept AccountNo and return an integer as explained below i) 1, if the AccountNo is existing and functional. ii) 2, if the AccountNo is existing, but deleted. iii) 0, if the AccountNo is not existing. c) Create a Stored Procedure/Function for Account Transaction The SP should accept AccountNo, Amount, Type of Transaction and Description and insert them into the AccountTransaction table. The field Transaction Date, should be the system date. This insertion should happen only if the following conditions are met. i) The AccountNo should exist. ii) The Amount should be a positive number. iii) The Type of transaction should be valid. iv) If the Type is ‘W’, sufficient amount should be available for the transaction. That is, the balance amount should be greater than or equal to 500 after withdrawal. The SP should also update CurrentAmount in the Account table. The SP should return an integer as explained below i) 1, if the AccountNo is invalid. ii) 2, if the Amount is not a positive number. iii) 3, if the fund is not sufficient. iv) 4, if the transaction is successful. v) 0, if transaction failed. ER/CORP/CRS/DB25/006 Version No. 1.0 Page 4 Infosys Project Specification for Oracle d) Create a Stored Procedure/Function for FundTransfer. The SP should accept FromAccountNo , ToAccountNo, Description and Amount and call the Account Transfer SP for withdrawing amount from the FromAccountNo and depositing amount to the ToAccountNo. The SP should return an integer as explained below i) 1, if the Account Number(s) is invalid. ii) 2, if the Amount is not positive. iii) 3, if the fund is not sufficient. iv) 4, if the transaction is successful. v) 0, if the transaction failed. e) Create a Stored Procedure/Function for generating the new customer ID. The SP should return the next customer ID. f) Create a Stored Procedure/Function for generating the new Account number. The SP should return the next account number. 2.8 Pro C Create the following Pro C program: a) Refer to the C module project and implement “Add a customer” functionality using Pro C. b) Refer to the C module project and implement “Deposit” functionality using Pro C. ER/CORP/CRS/DB25/006 Version No. 1.0 Page 5 . RESEARCH DEPARTMENT 1 PROJECT SPECIFICATION FOR ORACLE 1 1 BACKGROUND 1 2 BUSINESS REQUIREMENTS 1 ER/CORP/CRS/DB25 /00 6 Version No. 1. 0 i Infosys Project Specification for Oracle 1 Background This. Research Department Project Specification for Oracle Jul 200 5 Document No. Authorized By Ver. Revision Signature / Date ER/CORP/CRS/DB25/ 00 6 Dr. Ravindra M.P. Ver. 1. 0 Jul 200 5 COMPANY CONFIDENTIAL ©. Revision History Ver. Revision Date Author(s) Reviewer(s) Description 1. 00 Jul- 200 5 Sureesh Anubhav Nagendra Setty Rajagopalan P Initial write ER/CORP/CRS/DB25 /00 6 Version No. 1. 0 i © Infosys Technologies