sql assignment 1

3
1. Create a database ‘EmployeeDB’ with the following tables You have to choose the data types of the fields. Table name - Allowance ( intID - auto incrementing Primary Key, AllowanceID , Allowance Name ) Table name - Designation ( intID - auto incrementing Primary Key DesignationID , Designation Name ) Table name - Employee ( EmployeeID - auto incrementing Primary Key, FirstName , MiddleName, LastName, DateofBirth, DesignationID - FK to Designation table, MobileTelephone Address, City, State, Country, Gender (hint: bit field (true-male, false-female)) ) Table name - EmployeeAllowance ( intID - auto incrementing Primary Key EmployeeID – FK to Employee table, AllowanceID- FK to Allowance table, Amount ) Table name - DesignationAllowanceMapping (

Upload: anju-edadan

Post on 09-Apr-2017

131 views

Category:

Software


1 download

TRANSCRIPT

Page 1: Sql Assignment 1

1. Create a database ‘EmployeeDB’ with the following tablesYou have to choose the data types of the fields.

Table name - Allowance(intID - auto incrementing Primary Key,AllowanceID ,Allowance Name)

Table name - Designation(intID - auto incrementing Primary KeyDesignationID ,Designation Name)

Table name - Employee (EmployeeID - auto incrementing Primary Key,FirstName ,MiddleName,LastName,DateofBirth,DesignationID - FK to Designation table,MobileTelephoneAddress,City,State,Country,Gender (hint: bit field (true-male, false-female)))

Table name - EmployeeAllowance(intID - auto incrementing Primary KeyEmployeeID – FK to Employee table,AllowanceID- FK to Allowance table,Amount)

Table name - DesignationAllowanceMapping(intID - auto incrementing Primary KeyDesignationID – FK to Designation table,AllowanceID- FK to Allowance table)

Page 2: Sql Assignment 1

2. Write separate SQL Functions for the following

a. employee id as a parameter and outputs the total salary of that employeeb. employee id as a parameter and outputs the age of that employeec. employee id as a parameter and outputs employee id, name, designation, age, address, city, state, country, mobile telephone

3. Write a SQL Viewto get employee id, name, designation, age, address, city, state, country, mobile telephone, gender and total salary. Use the SQL functions which compute age and total salary in the view

4. Write a SQL Stored Procedure to get output in the following format. The stored procedure should use the view for employee details.

5. Write a stored procedure to get output in the following format. This stored procedure should not use the view and functions

No need to consider the above values in the output. Just the above format is required

Please send the answers by tomorrow 12pm. We shall have the call by 4pm.

You can send the answers in scripts.