Upload
adenm
View
214
Download
0
Tags:
Embed Size (px)
DESCRIPTION
IT
Citation preview
Case Study
Physical Database Design
Organization NameGemilang Tuition Center
Database Project NameG-HRIS (Gemilang-Human Resource Information System)
Prepared By Author Name
Part
4Physical Database Design
Introduction
Physical database design methodology is the third phase in the process of designing the database. It is a process to produce the implementation of database architecture will be implemented on secondary storage. It involves the process to reflect the storage structure and access methods to be used by the system efficiently and effectively.
This design process involves several stages, which the steps that need to be implemented are as follows:
Step 3 - Translate logical data model for target DBMS
3.1 - Design base relations 3.2 - Design representation of derived data 3.3 - Design enterprise constraints
Step 4 - Design file organizations and indexes
4.1 Analyze transactions 4.2 Choose file organizations 4.3 Choose Indexes 4.4 Estimate disk space requirements
Step 5 - Design User Views
Step 6 - Design security mechanisms
Step 7 - Consider the introduction of controlled redundancy
Step 8 - Monitor and tune the operational system
Step 3.1 - Design Base Relations For Selected DBMS
The first step in the process of physical database design is to produce a design of basic relationships identified in the logical data model to represent a more selected database. This is done by first producing a basic relationship with Extended Database Design Language [DBDL]).For a complete description of the Extended DBDL basic relationship has been identified in the logical data model, please refer diagram below.
Employee
Domain EmpID variable length character string length 6
Domain Name variable length character string length100
Domain DOB date, range from 1-Jan-1960, format d/m/yyyy
Domain ICNo variable length character string length 12
Domain Email variable length character string length 30
Domain Address variable length character string length 100
Domain PhoneNo variable length character string length 10
Domain DateHired Date, range from 1-Jan-2007, format d/my/yyyy
Domain YearOfServices computed, numeric
Domain Salary monetary:7 digits range 1000.00-15000.00
Domain JobStatusID variable length character string length 10
Domain GenderID character size 1, value M or F
Domain RaceID variable length character string length 10
Domain FamilyID variable length character string length 10
Domain BranchID variable length character string length 10
Domain DepartmentID variable length character string length 10
Domain DesignationID variable length character string length 10
Domain StatusOfMarriageID variable length character string length 30
Domain ReligionID variable length character string length 10
Employee(
EmpID EmployeeID NOT NULL
Name Name NOT NULL
DOB DOB NOT NULL
ICNo ICNo NOT NULL
Email Email
Address Address NOT NULL
PhoneNo PhoneNo NOT NULL
DateHired DateHired NOT NULL
YearOfServices YearOfServices
Salary Salary NOT NULL
JobStatusID JobStatusID NOT NULL
GenderID GenderID NOT NULL
RaceID RaceID NOT NULL
FamilyID FamilyID NOT NULL
BranchID BranchID NOT NULL
DepartmentID DepartmentID NOT NULL
DesignationID DesignationID NOT NULL
StatusOfMarriageID StatusOfMarriageID NOT NULL
ReligionID ReligionID NOT NULL
PRIMARY KEY (EmpID),
FOREIGN KEY (JobStatusID) REFERENCES JobStatus(JobStatusID) ON UPDATE CASCADE ON DELETE NO ACTION,
FOREIGN KEY (GenderID) REFERENCES Gender(GenderID) ON UPDATE CASCADE ON DELETE NO ACTION,
FOREIGN KEY (RaceID) REFERENCES Race(RaceID) ON UPDATE CASCADE ON DELETE NO ACTION,
FOREIGN KEY (FamilyID) REFERENCES Family(FamilyID) ON UPDATE CASCADE ON DELETE NO ACTION,
FOREIGN KEY (BranchID) REFERENCES Branch(BranchID) ON UPDATE CASCADE ON DELETE NO ACTION,
FOREIGN KEY (DepartmentID) REFERENCES Departmen (DepartmentID) ON UPDATE CASCADE ON DELETE NO ACTION,
FOREIGN KEY (DesignationID) REFERENCES Designation(DesignationID) ON UPDATE CASCADE ON DELETE NO ACTION,
FOREIGN KEY (StatusOfMarriageID) REFERENCES StatusOfMarriage(StatusOfMarriageID)
ON UPDATE CASCADE ON DELETE NO ACTION,
FOREIGN KEY (ReligionID) REFERENCES Religion(ReligionID) ON UPDATE CASCADE ON DELETE NO ACTION,
Transact-SQL syntax
CREATE TABLE [dbo].[Employee]([EmpID] [varchar](6) NOT NULL,[Name] [varchar](100) NOT NULL,[DOB] [datetime] NULL,[ICNo] [varchar](12) NULL,[Email] [varchar](100) NULL,[Address] [nvarchar](255) NULL,[PhoneNo] [nchar](10) NULL,[DateHired] [datetime] NULL,[YearOfServices] AS (floor(datediff(day,
[DateHired],getdate())/(365.25))),[Salary] [smallmoney] NOT NULL,[JobStatusID] [varchar](2) NOT NULL,[GenderID] [varchar](1) NOT NULL,[RaceID] [varchar](2) NOT NULL,[BranchID] [varchar](5) NOT NULL,[DepartmentID] [varchar](5) NOT NULL,[DesignationID] [varchar](5) NOT NULL,[StatusOfMarriageID] [varchar](2) NOT NULL,[ReligionID] [varchar](2) NOT NULL,
CONSTRAINT [PK_Employee] PRIMARY KEY CLUSTERED (
[EmpID] ASC)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]) ON [PRIMARY]
ALTER TABLE [dbo].[Employee] WITH CHECK ADD CONSTRAINT [FK_Employee_Branch] FOREIGN KEY([BranchID])REFERENCES [dbo].[Branch] ([BranchID])ON UPDATE CASCADE
ALTER TABLE [dbo].[Employee]WITH CHECK ADD CONSTRAINT [FK_Employee_Department] FOREIGN KEY([DepartmentID])REFERENCES [dbo].[Department] ([DepartmentID])
ON UPDATE CASCADE
ALTER TABLE [dbo].[Employee] WITH CHECK ADD CONSTRAINT [FK_Employee_Designation] FOREIGN KEY([DesignationID])REFERENCES [dbo].[Designation] ([DesignationID])ON UPDATE CASCADE
ALTER TABLE [dbo].[Employee] WITH CHECK ADD CONSTRAINT [FK_Employee_Gender] FOREIGN KEY([GenderID])REFERENCES [dbo].[Gender] ([GenderID])ON UPDATE CASCADE
ALTER TABLE [dbo].[Employee] WITH CHECK ADD CONSTRAINT [FK_Employee_JobStatus] FOREIGN KEY([JobStatusID])REFERENCES [dbo].[JobStatus] ([JobStatusID])ON UPDATE CASCADE
ALTER TABLE [dbo].[Employee] WITH CHECK ADD CONSTRAINT [FK_Employee_Race] FOREIGN KEY([RaceID])REFERENCES [dbo].[Race] ([RaceID])ON UPDATE CASCADE
ALTER TABLE [dbo].[Employee] WITH CHECK ADD CONSTRAINT [FK_Employee_Religion] FOREIGN KEY([ReligionID])REFERENCES [dbo].[Religion] ([ReligionID])ON UPDATE CASCADE
ALTER TABLE [dbo].[Employee] WITH CHECK ADD CONSTRAINT [FK_Employee_StatusOfMarriage] FOREIGN KEY([StatusOfMarriageID])REFERENCES [dbo].[StatusOfMarriage] ([StatusOfMarriageID])
ON UPDATE CASCADE
Family
Domain FamilyID variable length character string length 6
Domain EmpID variable length character string length 10
Domain RelationshipD variable length character string length 10
Domain Name variable length character string length 100
Domain Address variable length character string length 100
Domain PhoneNo variable length character string length 10
Family(
FamilyID FamilyID NOT NULL
EmpID EmployeeID NOT NULL
RelationshipID RelationshipID NOT NULL
Name Name NOT NULL
Address Address NOT NULL
PhoneNo PhoneNo NOT NULL
PRIMARY KEY (FamilyID),
FOREIGN KEY (EmployeeID) REFERENCES Employee(EmpID) ON UPDATE CASCADE ON DELETE NO ACTION,
FOREIGN KEY (RelationshipID) REFERENCES FamilyRelationship(RelationshipID) ON UPDATE CASCADE ON DELETE NO
ACTION,
Transact-SQL syntax
CREATE TABLE [dbo].[Family]([FamilyID] [int] IDENTITY(1,1) NOT NULL,[EmpID] [varchar](6) NOT NULL,[RelationshipID] [varchar](2) NULL,[Name] [varchar](100) NOT NULL,[Address] [nvarchar](255) NULL,[PhoneNo] [varchar](15) NULL,
CONSTRAINT [PK_Family] PRIMARY KEY CLUSTERED (
[FamilyID] ASC)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]) ON [PRIMARY]
ALTER TABLE [dbo].[Family] WITH CHECK ADD CONSTRAINT [FK_Family_Employee] FOREIGN KEY([EmpID])REFERENCES [dbo].[Employee] ([EmpID])ON UPDATE CASCADE
ALTER TABLE [dbo].[Family] WITH CHECK ADD CONSTRAINT [FK_Family_FamilyRelationship] FOREIGN KEY([RelationshipID])REFERENCES [dbo].[FamilyRelationship] ([RelationshipID])ON UPDATE CASCADE
Designation
Domain DesignationID variable length character string length 6
Domain DesignationName variable length character string length 100
Domain EmploymentTypeID variable length character string length 10
Designation(
DesignationID DesignationID NOT NULL
DesignationName DesignationName NOT NULL
EmploymentTypeID EmploymentTypeID NOT NULL
PRIMARY KEY (DesignationID),
FOREIGN KEY (EmploymentTypeID) REFERENCES EmploymentType(EmploymentTypeID) ON UPDATE CASCADE ON DELETE
NO ACTION,
Transact-SQL syntax
CREATE TABLE [dbo].[Designation]([DesignationID] [varchar](5) NOT NULL,[DesignationName] [varchar](50) NOT NULL,[EmploymentTypeID] [varchar](2) NOT NULL,
CONSTRAINT [PK_Designation] PRIMARY KEY CLUSTERED (
[DesignationID] ASC)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]) ON [PRIMARY]
ALTER TABLE [dbo].[Designation] WITH CHECK ADD CONSTRAINT [FK_Designation_EmploymentType] FOREIGN KEY([EmploymentTypeID])REFERENCES [dbo].[EmploymentType] ([EmploymentTypeID])
ON UPDATE CASCADE
Job Status
Domain JobStatusID variable length character string length 6
Domain JobStatus variable length character string length 20
JobStatus(
JobStatusID JobStatusID NOT NULL
JobStatus JobStatus NOT NULL
PRIMARY KEY (JobStatusID),
Transact-SQL syntax
CREATE TABLE [dbo].[JobStatus]([JobStatusID] [varchar](2) NOT NULL,[JobStatus] [varchar](20) NOT NULL,
CONSTRAINT [PK_JobStatus] PRIMARY KEY CLUSTERED (
[JobStatusID] ASC)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]) ON [PRIMARY]
Race
Domain RaceID variable length character string length 2
Domain Race variable length character string length 20
Race(
RaceID RaceID NOT NULL
Race Race NOT NULL
PRIMARY KEY (RaceID),
Transact-SQL syntax
CREATE TABLE [dbo].[Race]([RaceID] [varchar](2) NOT NULL,[Race] [varchar](20) NOT NULL,
CONSTRAINT [PK_Race] PRIMARY KEY CLUSTERED (
[RaceID] ASC)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]) ON [PRIMARY]
Gender
Domain GenderID variable length character string length 1
Domain Gender variable length character string length 20
Gender(
GenderID GenderID NOT NULL
Gender Gender NOT NULL
PRIMARY KEY (GenderID),
Transact-SQL syntax
CREATE TABLE [dbo].[Gender]([GenderID] [varchar](1) NOT NULL,[Gender] [varchar](20) NOT NULL,
CONSTRAINT [PK_Gender] PRIMARY KEY CLUSTERED (
[GenderID] ASC)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]) ON [PRIMARY]
Branch
Domain BranchID variable length character string length 5
Domain BranchName variable length character string length 100
Domain Address variable length character string length 255
Domain HeadOfBranch variable length character string length 6
Department(
BranchID BranchID NOT NULL
BranchName BranchName NOT NULL
Address Address NOT NULL
HeadOfBranchID HeadOfBranchID NOT NULL
PRIMARY KEY (BranchID),
FOREIGN KEY (HeadOfBranchID) REFERENCES Employee(EmpID) ON UPDATE NO ACTION ON DELETE NO ACTION
Transact-SQL syntax
CREATE TABLE [dbo].[Branch]([BranchID] [varchar](5) NOT NULL,[BranchName] [varchar](100) NOT NULL,[Address] [nvarchar](255) NULL,[HeadOfBranchID] [varchar](6) NOT NULL,
CONSTRAINT [PK_Branch] PRIMARY KEY CLUSTERED (
[BranchID] ASC)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]) ON [PRIMARY]
ALTER TABLE [dbo].[Branch] WITH CHECK ADD CONSTRAINT [FK_Branch_HOB] FOREIGN KEY([HeadOfBranchID])REFERENCES [dbo].[Employee] ([EmpID])
StatusOfMarriage
Domain StatusOfMarriageID variable length character string length 2
Domain Status variable length character string length 20
StatusOfMarriage(
StatusOfMarriageID StatusOfMarriageID NOT NULL
Status Status NOT NULL
PRIMARY KEY (StatusOfMarriageID),
Transact-SQL syntax
CREATE TABLE [dbo].[StatusOfMarriage]([StatusOfMarriageID] [varchar](2) NOT NULL,[StatusOfMarriage] [varchar](20) NOT NULL,
CONSTRAINT [PK_StatusOfMarriage] PRIMARY KEY CLUSTERED (
[StatusOfMarriageID] ASC)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]) ON [PRIMARY]
Religion
Domain ReligionID variable length character string length 2
Domain Religion variable length character string length 50
Religion(
ReligionID ReligionID NOT NULL
Religion Religion NOT NULL
PRIMARY KEY (ReligionID),
Transact-SQL syntax
CREATE TABLE [dbo].[Religion]([ReligionID] [varchar](2) NOT NULL,[Religion] [varchar](50) NOT NULL,
CONSTRAINT [PK_Religion] PRIMARY KEY CLUSTERED (
[ReligionID] ASC)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
FamilyRelationship
Domain FamilyRelationshipID variable length character string length 2
Domain Relationship variable length character string length 15
FamilyRelationship (
RelationshipID RelationshipID NOT NULL
Relationship Relationship NOT NULL
PRIMARY KEY (RelationshipID),
Transact-SQL syntax
CREATE TABLE [dbo].[FamilyRelationship]([RelationshipID] [varchar](2) NOT NULL,[Relationship] [varchar](15) NOT NULL,
CONSTRAINT [PK_FamilyRelationship] PRIMARY KEY CLUSTERED (
[RelationshipID] ASC)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
EmploymentType
Domain EmploymentTypeID variable length character string length 2
Domain Type variable length character string length 50
EmploymentTypeID (
EmploymentTypeID EmploymentTypeID NOT NULL
Type EmploymentType NOT NULL
PRIMARY KEY (EmploymentTypeID),
Transact-SQL syntax
CREATE TABLE [dbo].[EmploymentType]([EmploymentTypeID] [varchar](2) NOT NULL,[Type] [varchar](50) NOT NULL,
CONSTRAINT [PK_EmploymentType] PRIMARY KEY CLUSTERED (
[EmploymentTypeID] ASC)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]) ON [PRIMARY]
SubjectExpert
Domain SubjectExpertID Auto number
Domain EmpID variable length character string length 6
Domain SubjectLevelID variable length character string length 10
Domain SinceDate Date, range from 1-Jan-1980, format d/m/yyyy
Domain YearsExperience Derived (Current year – SinceDate)
SubjectExpert (
SubjectExpertID SubjectExpertID NOT NULL
EmpID EmpID NOT NULL
SubjectLevelID SubjectLevelID NOT NULL
SinceDate Date NOT NULL
PRIMARY KEY (SubjectExpertID),
FOREIGN KEY (SubjectLevelID) REFERENCES SubjectLevel(SubjectLevelID) ON UPDATE CASCADE ON DELETE NO ACTION
Transact-SQL syntax
CREATE TABLE [dbo].[SubjectExpert]([SubjectExpertID] [int] IDENTITY(1,1) NOT NULL,[EmpID] [varchar](6) NOT NULL,[SubjectLevelID] [varchar](10) NOT NULL,[SinceDate] [datetime] NOT NULL,[YearsExperience] AS (floor(datediff(day,
[SinceDate],getdate())/(365.25))), CONSTRAINT [PK_SubjectExpert] PRIMARY KEY CLUSTERED
([SubjectExpertID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]) ON [PRIMARY]
ALTER TABLE [dbo].[SubjectExpert] WITH CHECK ADD CONSTRAINT [FK_SubjectExpert_SubjectLevel] FOREIGN KEY([SubjectLevelID])REFERENCES [dbo].[SubjectLevel] ([SubjectLevelID])ON UPDATE CASCADE
ALTER TABLE [dbo].[SubjectExpert] WITH CHECK ADD CONSTRAINT [CK_SinceDate] CHECK ((floor(datediff(day,[SinceDate],getdate())/(365.25))>=(2)))
SubjectTeach
Domain EmpID variable length character string length 6
Domain SubjectLevelID variable length character string length 10
Domain YearSession Integer, default current year
SubjectTeach (
EmpID EmpID NOT NULL
SubjectLevelID SubjectLevel NOT NULL
Date Date NOT NULL
Description Decription NOT NULL
PRIMARY KEY (SubjecLevelID),(EmpID), (YearSession)
FOREIGN KEY (EmpID) REFERENCES Employee(EmpID) ON UPDATE CASCADE ON DELETE NO ACTION
FOREIGN KEY (SubjectLevelID) REFERENCES SubjectLevel(SubjectLevelID) ON UPDATE CASCADE ON DELETE NO ACTION
Transact-SQL syntax
CREATE TABLE [dbo].[SubjectTeach]([EmpID] [varchar](6) NOT NULL,[SubjectLevelID] [varchar](10) NOT NULL,[YearSession] [int] NOT NULL CONSTRAINT [DF_SubjectTeach_year]
DEFAULT (datepart(year,getdate())), CONSTRAINT [PK_SubjectTeach_1] PRIMARY KEY CLUSTERED (
[EmpID] ASC,[SubjectLevelID] ASC,[YearSession] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]) ON [PRIMARY]
ALTER TABLE [dbo].[SubjectTeach] WITH CHECK ADD CONSTRAINT [FK_SubjectTeach_SubjectLevel] FOREIGN KEY([SubjectLevelID])REFERENCES [dbo].[SubjectLevel] ([SubjectLevelID])ON UPDATE CASCADE
EmpQualification
Domain EmpID variable length character string length 6
Domain QualificationID variable length character string length 6
Domain QualificationName variable length character string length 100
Domain InstitutionName variable length character string length 100
Domain YearAttended Integer
Domain HighestFlag bit
EmpQualification (
EmpID EmpID NOT NULL
QualificationID Qualification NOT NULL
QualificationName Qualification NOT NULL
InsitutationName InsitutationName NOT NULL
YearAttended YearAttended NOT NULL
HighestFlag HighestFlag NOT NULL
PRIMARY KEY (EmpID),(QualificationID)
FOREIGN KEY (EmpID) REFERENCES Employee(EmpID) ON UPDATE CASCADE ON DELETE CASCADE
FOREIGN KEY (QualificationID) REFERENCES Qualification (QualificationID) ON UPDATE CASCADE ON DELETE NO ACTION
Transact-SQL syntax
CREATE TABLE [dbo].[EmpQualification]([EmpID] [varchar](6) NOT NULL,[QualificationID] [varchar](6) NOT NULL,[QualificationName] [nvarchar](100) NOT NULL,[InstitutionName] [nvarchar](100) NULL,[YearAttended] [int] NULL,[HighestFlag] [bit] NOT NULL CONSTRAINT
[DF_EmpQualification_HighestFlag] DEFAULT ((1)), CONSTRAINT [PK_EmpQualification] PRIMARY KEY CLUSTERED (
[EmpID] ASC,[QualificationID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
ALTER TABLE [dbo].[EmpQualification] WITH CHECK ADD CONSTRAINT [FK_EmpQualification_Employee] FOREIGN KEY([EmpID])REFERENCES [dbo].[Employee] ([EmpID])ON UPDATE CASCADEON DELETE CASCADE
ALTER TABLE [dbo].[EmpQualification] WITH CHECK ADD CONSTRAINT [FK_EmpQualification_Qualification] FOREIGN KEY([QualificationID])REFERENCES [dbo].[Qualification] ([QualificationID])ON UPDATE CASCADE
SubjectLevel
Domain SubjectLevelID variable length character string length 10
Domain SubjectID variable length character string length 6
Domain LevelID variable length character string length 6
Domain Description variable length character string length 50
SubjectLevel (
SubjectLevelID SubjectLevel NOT NULL
SubjectID Subject NOT NULL
LevelID Level NOT NULL
Description Description NOT NULL
PRIMARY KEY (SubjectLevelID)
FOREIGN KEY (SubjectID) REFERENCES Subject(SubjectID) ON UPDATE CASCADE ON DELETE NO ACTION
FOREIGN KEY (LevelID) REFERENCES Level(LevelID) ON UPDATE CASCADE ON DELETE NO ACTION
Transact-SQL syntax
CREATE TABLE [dbo].[SubjectLevel]([SubjectLevelID] [varchar](10) NOT NULL,[SubjectID] [varchar](6) NOT NULL,[LevelID] [varchar](6) NOT NULL,[Description] [varchar](50) NOT NULL,
CONSTRAINT [PK_SubjectLevel] PRIMARY KEY CLUSTERED (
[SubjectLevelID] ASC)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]) ON [PRIMARY]
ALTER TABLE [dbo].[SubjectLevel] WITH CHECK ADD CONSTRAINT [FK_SubjectLevel_Level] FOREIGN KEY([LevelID])REFERENCES [dbo].[Level] ([LevelID])ON UPDATE CASCADE
ALTER TABLE [dbo].[SubjectLevel] WITH CHECK ADD CONSTRAINT [FK_SubjectLevel_Subject] FOREIGN KEY([SubjectID])REFERENCES [dbo].[Subject] ([SubjectID])
ON UPDATE CASCADE
Subject
Domain SubjectlID variable length character string length 6
Domain Subject variable length character string length 50
Subject (
SubjectID SubjectID NOT NULL
Subject Subject NOT NULL
PRIMARY KEY (SubjectID)
Transact-SQL syntax
CREATE TABLE [dbo].[Subject]([SubjectID] [varchar](6) NOT NULL,[Subject ] [varchar](50) NOT NULL,
CONSTRAINT [PK_Subject] PRIMARY KEY CLUSTERED (
[SubjectID] ASC)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]) ON [PRIMARY]
Level
Domain LevelID variable length character string length 6
Domain Level variable length character string length 50
Level (
LevelID LevelID NOT NULL
Level Level NOT NULL
PRIMARY KEY (LevelID)
Transact-SQL syntax
CREATE TABLE [dbo].[Level]([LevelID] [varchar](6) NOT NULL,[Level] [nvarchar](50) NOT NULL,
CONSTRAINT [PK_Level] PRIMARY KEY CLUSTERED (
[LevelID] ASC)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]) ON [PRIMARY]
Qualification
Domain QualificationID variable length character string length 6
Domain QualificationName variable length character string length 50
Qualification ( QualificationID QualificationID NOT NULL QualificationName QualificationName NOT NULL
PRIMARY KEY (QualificationID)
Transact-SQL syntax
CREATE TABLE [dbo].[Qualification]([QualificationID] [varchar](6) NOT NULL,[Description] [nvarchar](50) NOT NULL,
CONSTRAINT [PK_Qualification] PRIMARY KEY CLUSTERED (
[QualificationID] ASC)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]) ON [PRIMARY]
Step 3.2 - Design representation of derived data
The purpose of design representation of derived data is to decide any derived data present in the logical data model in target DBMS. Attributes whose value can be found by examining the values of others attributes are known as derived or calculated attributes. The examples of derived data are:-
1. The year of service of employee
2. The year of experience of the teacher’s subject expert
Step 3.3 - Design enterprise constraints
The objective of design enterprise constraints is to design the general constraints for target DBMS. The design should be fully documented. In particular, document the reason for selecting one approach where many alternatives exist. Design enterprise constraints can be implemented by using DBMS or application programming language such as Java, C++, VB.NET and ASP. The example of design enterprise constraints can be shown as below.
Constraint 1: Only teachers who have at least 2 years teaching experience for the respective subject and level will be considered as an Expert for that particular subject and level.
The following INSERT statement should fail with the error shown below.
CONSTRAINT [CK_SinceDate]CHECK((floor(datediff(day,[SinceDate],getdate())/(365.25))>=(2)))
Constraint 2: Teacher is not allowed to teach more than 5 subjects level in one year session
This constraint is implemented by using triggers
Create TRIGGER [CheckNoOfTeacherSubjectTeach] ON [dbo].[SubjectTeach]FOR INSERTASIF EXISTS (SELECT EmpID
FROM [SubjectTeach] GROUP BY EmpID, YearSession HAVING COUNT(*) > 5)
BEGIN RAISERROR('You cannot add more than 5 subject level for each teacher in one session!',16,1) ROLLBACK RETURNEND
The following INSERT statement should fail with the error shown below.
Step 4.1 - Analyse Transactions
These steps involved in analyzing the database transaction for understanding the functionality of the transaction that will run on the database. In also allows us to analyze and identify the key transactions in the database to be implemented.
Map all transaction paths to relations.
A : Enter the details for Employees
B : List the subject teached by teacher.
C : List the teacher’s subject expert.
D : List the number of teachers by subject and level.
TRANSACTION / RELATION
A B C D
I R U D I R U D I R U D I R U D
Employee X X X X X X X
JobStatus X
Race X
Gender X
Family X
FamilyRelationship
X
Branch X X X X
Department X
Designation X X X X
EmploymentType X
StatusOfMarriage X
Religion X
Level X X X
Subject X X X
SubjectLevel X X X
SubjectExpert X
SubjectTeach X X
Qualification
EmpQualification
Transactions usage map.
avg = 10max = 20
avg = 200max = 300
avg = 10max = 20
78
SubjectTeach
22
SubjectLevel
11
Level
23
Subject10
SubjectExpert
108
Employee
Transaction by year session
0..1 0..3 is a
0..1 1..* 1..1
teach refers to refers to
0..* 1..1 1..*
1..* 1..1 1..* 1..* refers to refers to
Step 4.2 - Choose file organizations
One of the main objectives of physical database design is to store and access data in an efficient way. The objective of this step is to determine the best file organization for each identified relationship to access records and updates the records can be implemented efficiently. This step is based on on the functionality in target DBMS. If the target DBMS does not allow to choice of file organization, this step can be omitted.
Here, there are two files of the selected structures for implementing of this system by choosing Microsoft SQL Server:
1)Heap
2) B + Tree
Heap
"Heap" is selected for the implementation of this database, there is a relationship in which all records in relationships are achieved simultaneously at a time without any condition on data access. In addition, Heap is also appropriate in circumstances where records for a simultaneous relationship should be substantially related to the relationship. This situation exists in the implementation of this database.
Here is a relation that used the Heap file organization:
1. JOBSTATUS2. RACE3. GENDER4. FAMILY5. FAMILYRELATIONSHIP6. BRANCH7. DESIGNATION8. EMPLOYMENTTYPE9. STATUSOFMARRIAGE10. RELIGION11. LEVEL12. SUBJECT13. QUALIFICATION
B+ Tree
The second structure is the organization selected B + Tree. The purpose of selecting B+Tree file organization because it is quite efficient in achieving the data based on the range given to achieve the data. B + Tree file organization also has a dynamic structure during data growth up in a relationship. Apart from these factors, B + Tree chosen for Microsoft SQL Serverwill place the data in the organization B + Tree, if a particular relationship has a tuple that is classified as clustered.
Here is a relation that used the B+Tree file organization:
1. EMPLOYEE2. SUBJECTEXPERT3. SUBJECTTEACH4. EMPQUALIFICATION5. SUBJECTLEVEL6. DEPARTMENT
4.3 – Choose Indexes
One approach to selecting an appropriate file organization for relation is to keep the tuple unordered and create as many secondary indexes as necessary. The main purpose of choose indexes is to determine whether adding indexes will improve the performance of the system.
DEPARTMENT
i. Attribute: DepartmentID
CLUSTERED: Yes
UNIQUE: Yes
Script in Microsoft SQL Server
CREATE CLUSTERED INDEX PK_DEPARTMENT ON DEPARTMENT (DepartmentID
) WITH FILLFACTOR=80
GO
DESIGNATION
ii. Attribute: DesignationID
CLUSTERED: Yes
UNIQUE: Yes
Script in Microsoft SQL Server
CREATE CLUSTERED INDEX PK_DESIGNATION ON DESIGNATION (DesignationID
) WITH FILLFACTOR=80
GO
Step 4.4 – Estimate Disk requirement Space
The estimate is based on the size of each tuple and the number of tuples in the relation. The latter estimate should be a maximum number but it may also be worth considering how the relation will grow and modifying the resulting disk size by this growth factor to determine the potential size of the database in the future.
Step 5 –Design User Views
Design the user views that were identified during the requirement collection and analysis stage of the relational database system development lifecycle. We identified five user views for Gemilang Human Resource Information System named Principal, Admin Executive, Coordinator, Teacher and Staff (for common staff). Following an analysis of the data requirements for this user views, we used the centralized approach to merge the requirement for the user views as follows:
Principal and Admin Executive view – can view all
Coordinator view – can view teacher records including personal data (except salary column), qualification, subject teached and subject expert.
Teacher view – can view their own personal data, family, qualification, subject teached and subject expert
Staff view – can view their own personal data, family and qualification
Step 6 – Design Security Mechanisms
Design the security measures for the database system as specified by the user.
Design Security Database Access Level for Admin Executive
GRANT SELECT,INSERT,UPDATE,DELETE ON EMPLOYEE TO Admin_ExecGOGRANT SELECT,INSERT,UPDATE,DELETE ON BRANCH TO Admin_ExecGOGRANT SELECT,INSERT,UPDATE,DELETE ON DEPARTMENT TO Admin_ExecGOGRANT SELECT,INSERT,UPDATE,DELETE ON DESIGNATION TO Admin_ExecGOGRANT SELECT,INSERT,UPDATE,DELETE ON EMPLOYMENTTYPE TO Admin_ExecGOGRANT SELECT,INSERT,UPDATE,DELETE ON EMPQUALIFICATION TO Admin_ExecGOGRANT SELECT,INSERT,UPDATE,DELETE ON FAMILY TO Admin_ExecGOGRANT SELECT,INSERT,UPDATE,DELETE ON FAMILYRELATIONSHIP TO Admin_ExecGOGRANT SELECT,INSERT,UPDATE,DELETE ON GENDER TO Admin_ExecGOGRANT SELECT,INSERT,UPDATE,DELETE ON JOBSTATUS TO Admin_ExecGOGRANT SELECT,INSERT,UPDATE,DELETE ON QUALIFICATION TO Admin_ExecGOGRANT SELECT,INSERT,UPDATE,DELETE ON RACE TO Admin_ExecGOGRANT SELECT,INSERT,UPDATE,DELETE ON RELIGION TO Admin_ExecGOGRANT SELECT,INSERT,UPDATE,DELETE ON STATUSOFMARRIAGE TO Admin_ExecGOGRANT SELECT ON SUBJECT TO Admin_ExecGOGRANT SELECT ON [LEVEL] TO Admin_ExecGOGRANT SELECT ON SUBJECTLEVEL TO Admin_ExecGOGRANT SELECT ON VIEW_SUBJECTEXPERT TO Admin_ExecGOGRANT SELECT ON VIEW_TEACHERSUBJECTTEACH TO Admin_ExecGOGRANT SELECT ON VIEW_FAMILY TO Admin_ExecGOGRANT SELECT ON VIEW_QUALIFICATION TO Admin_ExecGO
Design Security Database Access Level for Coordinator
GRANT SELECT,INSERT,UPDATE,DELETE ON SUBJECT TO CoordinatorGOGRANT SELECT,INSERT,UPDATE,DELETE ON [LEVEL] TO CoordinatorGOGRANT SELECT,INSERT,UPDATE,DELETE ON SUBJECTTEACH TO CoordinatorGOGRANT SELECT,INSERT,UPDATE,DELETE ON SUBJECTLEVEL TO CoordinatorGOGRANT SELECT,INSERT,UPDATE,DELETE ON SUBJECTEXPERT TO CoordinatorGOGRANT SELECT ON EMPQUALIFICATION TO CoordinatorGOGRANT SELECT ON QUALIFICATION TO CoordinatorGOGRANT SELECT ON VIEW_TEACHER TO CoordinatorGOGRANT SELECT ON VIEW_SUBJECTEXPERT TO CoordinatorGOGRANT SELECT ON VIEW_TEACHERSUBJECTTEACH TO CoordinatorGOGRANT SELECT ON VIEW_FAMILY TO CoordinatorGOGRANT SELECT ON VIEW_QUALIFICATION TO CoordinatorGO
Design Security Database Access Level for Principal
GRANT SELECT ON EMPLOYEE TO principalGOGRANT SELECT ON BRANCH TO principalGOGRANT SELECT ON DEPARTMENT TO principalGOGRANT SELECT ON DESIGNATION TO principalGOGRANT SELECT ON EMPLOYMENTTYPE TO principalGOGRANT SELECT ON EMPQUALIFICATION TO principalGOGRANT SELECT ON FAMILY TO principalGOGRANT SELECT ON FAMILYRELATIONSHIP TO principalGOGRANT SELECT ON GENDER TO principalGOGRANT SELECT ON JOBSTATUS TO principalGOGRANT SELECT ON QUALIFICATION TO principalGOGRANT SELECT ON RACE TO principalGO
GRANT SELECT ON RELIGION TO principalGOGRANT SELECT ON STATUSOFMARRIAGE TO principalGOGRANT SELECT ON VIEW_SUBJECTEXPERT TO principalGOGRANT SELECT ON VIEW_TEACHERSUBJECTTEACH TO principalGOGRANT SELECT ON VIEW_FAMILY TO principalGOGRANT SELECT ON VIEW_QUALIFICATION TO principalGO
Design Security Database Access Level for Branch Manager
GRANT SELECT ([EMP ID], NAME, DOB, [IC NO], EMAIL, ADDRESS, PHONENO,[JOIN DATE], [YEAR OF SERVICES], [JOB STATUS],RACE, [EMP TYPE],[MARRIED STATUS], RELIGION, DESIGNATIONNAME,DEPARTMENTNAME, BRANCHNAME) ON VIEW_EMPLOYEE TO Branch_ManagerGOGRANT SELECT ON EMPQUALIFICATION TO Branch_Manager GOGRANT SELECT ON QUALIFICATION TO Branch_Manager GOGRANT SELECT ON VIEW_TEACHER TO Branch_Manager GOGRANT SELECT ON VIEW_TEACHERSUBJECTTEACH TO Branch_ManagerGOGRANT SELECT ON VIEW_FAMILY TO Branch_ManagerGOGRANT SELECT ON VIEW_QUALIFICATION TO Branch_ManagerGO
Design Security Database Access Level for Teacher
GRANT SELECT ON VIEW_FAMILY TO TeacherGOGRANT SELECT ON VIEW_QUALIFICATION TO TeacherGOGRANT SELECT ON VIEW_TEACHER TO Teacher GOGRANT SELECT ON VIEW_TEACHERSUBJECTTEACH TO TeacherGOGRANT SELECT ON VIEW_SUBJECTEXPERT TO TeacherGO
Design Security Database Access Level for Staff
GRANT SELECT ([EMP ID], NAME, DOB, [IC NO], EMAIL, ADDRESS,PHONENO [JOIN DATE], [YEAR OF SERVICES], [JOB STATUS],RACE, [EMP TYPE],[MARRIED
STATUS], RELIGION, DESIGNATIONNAME,DEPARTMENTNAME, BRANCHNAME) ON VIEW_EMPLOYEE TO StaffsGOGRANT SELECT ON VIEW_FAMILY TO StaffGOGRANT SELECT ON VIEW_QUALIFICATION TO StaffGO
Step 7 – Consider the Introduction of Controlled Redundancy
Determine whether introducing redundancy in a controlled manner by relaxing the normalization rules will improve the performance of the system. For example, consider duplicating attributes or joining relations together.
Step 8 – Monitor and Tune the Operational System
Monitor the operational system and improve performance of the system to correct inappropriate design decisions or reflect changing requirements.