DAD Assignment
DAD Assignment
Assessment Title & No’s : Database solution for Naomi Villa (No 1 of 1)
I hereby, declare that I know what plagiarism entails, namely to use another’s work and
to present it as my own without attributing the sources in the correct way. I further
understand what it means to copy another’s work.
Naomi Villa is a five star hotel situated in the southern border of Sri Lanka, awarded as
the best of its category by the president, several times.
Naomi Villa has 5 categories of rooms namely Standard, Superior, Deluxe, Suits and
Penthouses. All five categories are offered in either of two types “Garden View” or
“Ocean View”. Standard, Superior and Deluxe categories can be ordered in any of three
bed sizes, known as “King” best suited for couples, “Queen” suited for Singles, or
“Twins” which is two separate single beds for travel partners. Suits have “King” and
“Twin Set” size beds where Penthouses can only be ordered with “King” size beds.
Room bed configuration and the view are native to the room and cannot be changed as
desired. The five different room categories are priced at a variation, but within a
category, the price remains the same regardless of the bed type and size or view.
Naomi Villa has several types of Clients, collectively known as “Guests”. A Guest can be
either “Direct” who booked the hotel directly, “repeat” who has visited another hotel
before or “Agent” who booked through third party travel agents. Different client types are
offered rooms at different prices.
Customers willing to make a stay in the hotel must first make an inquiry, inquiries are
recorded for further follow up and promotional purposes. After the inquiry, customer can
make an advance payment, which makes the inquiry a confirmed booking. While making
a booking, the customer has to specify the preferred room type, view, bed size, stay
period, etc.
Clients are also free to select one of any of the three meal plans during reservation. The
meal plans include “BB” where breakfast is included in the room bill, “HB” where
breakfast and Dinner is included and “FB” where all three meals are included.
Upon arrival, the Guest card is filled, and filed for the duration of stay, and archived after
the departure of the client. If the client visits the hotel again, the information in the
archived guest card is used to create a reservation for the new stay. Guest card collects
the Customer Name(s), Birthday(s), ID Number(s), Address(s) and Phone Number(s).
After the registration, the customer is escorted into his/her room.
Naomi villa has a selection of restaurants, bars, sports, tour and healthcare treatment
facilities which the guests can enjoy during his/her stay. Each facility requires a prior
booking, for example, a customer can book a romantic dinner for two, at the special roof
top restaurant named “temptations” and request for jasmine scented candles. Charges for
such utilization are credited to the customer’s “room account” which the Guest can pay
during his “Check-out” either by cash or credit card.
After the check-out, guest records including his personal details, preference and
information related to his stay are archived along with the Guest card, which can be
called upon to verify a re-visiting customer.
Task 2
2.1. Draw an ER diagram for the above scenario. Make sure to indicate
primary keys, cardinality constraints, weak entities (if any), and participation
constraints.
2.2. List any assumptions and extra constraints which cannot be captured by
the ER diagram.
2.3. For each entity set and relationship, write a short description in plain
English of what it represents or models.
2.4. Translate the ER diagram in Relational Schemas. (LO 2.1)
2.5. Translate the ER diagram into relational database tables (give the SQL
DDL statements). (LO 2.2)
2.6. Provide evidence of the use of a suitable IDE to create a simple interface
to insert, update and delete data in the database (LO 2.3)
Task 3
3.1. Explain and provide evidence on the benefits gained when making use of
DML (LO 3.1) (M 1.2)
3.2. After creating the tables, execute the following SQL queries on your
database.
For each of the problems show:
• Your SQL query
• The result you obtained (LO 3.2)
3.3. How meaningful data has been extracted through the use of query tools.
Explain with examples. (LO 3.3)
3.4. Provide suitable test cases and a test plan to test the database.(LO 4.1)(LO
4.2)
3.5. Demonstrate how MS SQL effectively supporting to the designer when
they implement the database through the documentation. (User screen shots)
(LO 4.3)
3.6. Explain how verification and validation are addressed in your database
using stored procedures.(LO 4.4)
3.7. Discuss the security policies relevant to any database management system.
(LO4.5)
Comments:
Assessor Name :
Assessor Signature:
Possible
Outcomes/Criteria for PASS Page Feedback
evidence
Assessor: Signature:
Date: ____/____/______
1.3.10 Implementation.................................................................................................30
1.3.12 Testing...............................................................................................................30
Facilities details............................................................................................................35
2.6 Interfaces................................................................................................................40
3.1 Explain and provide evidence on the benefits gained when making use of DML.51
3.2.1 Filter the customers who have made prior booking for special facilities...........54
3.2.2 Delete the records of customers who have booked ‘Deluxe’ rooms...................55
3.4 Provide suitable test cases and a test plan to test the database...............................60
Non-functional testing..................................................................................................63
3.6 Verification............................................................................................................74
3.7 Triggers..................................................................................................................79
Gantt chart....................................................................................................................83
Self Criticism...............................................................................................................84
Summary......................................................................................................................85
Indexes.........................................................................................................................86
Glossary........................................................................................................................87
List of Tables
It is of greatest and extreme gratitude and with the help and guideline of one person, our
wonderful lecturer Miss Malsha. Therefore the completion of this assignment gives us
much pleasure. Our sincere gratitude to Miss Malsha and to the whole administration of
Esoft for giving us a good guideline in helping us in our assignments.
You have guided us in every possible way and we are grateful. From a certain point of
view, we can always ask anything from you and we are certain that you will certainly
help us in every possible way.
Her valuable guidance and advice has inspired us greatly to work in this project. Thus,
her willingness to motivate us has contributed tremendously to the completion of this
assignment.
To end all I have to say or mention is about a famous quote about Education –
“Education is the most powerful weapon which you can use to change the world.
Prepare a power point presentation to critically compare and contrast different data
models and provide suitable justifications for why relational model best fits the
scenario
Fig
ure 10 Object Oriented Model contd
Fig
ure 16 Advantages of Data Warehouse
Fig
ure 18 Disadvantages of Data Warehouse
Database design is the process of producing a detailed data model of a database. This data
model contains all the needed logical and physical design choices and physical storage
parameters that are needed to generate a design in a data definition language, which can
be used to create a database.
Source (www.tutorialpoint.com)
Source (www.amk.fi)
The top-down approach, also known as step-wise design, essentially breaks a system or
model down into component sub-systems, each of which may further broken down
further. However, no first-level system are defined – you won’t describe a for loop, or
define the attributes of an object in the top-down approach. Systems end up as a series of
‘black boxes’; components that have specific inputs and outputs, but no definite internal
structure.
Bottom Up
Bottom-up design consists of defining and coding the very basic, definite parts of the
system to be designed, then linking these parts together to form the whole. It also
identifies the data elements (items) and then groups them together in data sets. In other
words, it first defines attributes, and then groups them to form entities. Bottom up begins
with the specific details and moves up to the general. It identifies the data elements and
then groups them together in data sets.
It starts with the top level module and progresses downward to the lowest level
module
Bottom Up
It’s just the reverse as it begins with the concrete design to get the abstract entity
The very first step in database planning is to define the mission statement and objectives
for the database system. It is the major aim, the purpose and the supported tasks of the
database system which are known as the resources of the database system
The major user views are also described. I.e. what is required of a database system from
the perspectives of particular job roles or enterprise application areas?
Source (www.amk.fi)
In the conceptual design phase, the model of the data to be used is to be independent of
all physical considerations which are to be constructed. The model is based on the
requirements specification
In the logical database design phase, the model of the data to be used is based on a
specific data model, but independent of a particular database management system is
constructed. This is based on the target data model for the database e.g. relational data
model.
In the physical database design phase, the description of the implementation of the
database on secondary storage is created. The base relations, indexes, integrity
constraints, security, etc. are defined using the SQL language.
In this phase the criteria for the new DBMS are defined. Then several products are
evaluated according to the criteria. Finally the recommendation for the selection is
decided.
In the application design phase, the design of the user interface and the application
programs that use and process the database are defined and designed. It includes database
concerns such as interfacing SQL with traditional programming languages
1.3.9 Prototyping
The purpose of a prototype is to allow the users to use the prototype to identify the
features of the system using a computer.
There are horizontal and vertical prototypes. A horizontal prototype has many features
(e.g. user interfaces) but they are not in a working condition. A vertical prototype has
very few features but they are in perfect working condition.
1.3.10 Implementation
During the implementation phase, the physical realizations of the database and
application designs are to be done. This is the programming phase of the systems
development.
1.3.12 Testing
Before the new system is going to live, it should be thoroughly tested. The goal of testing
is to find errors! The goal is not to prove the software is working well.
Monitoring means that the performance of the system is observed. If the performance of
the system falls below an acceptable level, tuning or reorganization of the database may
be required
Source (www.amk.fi)
UNIQUE
User is prohibited to insert duplicate values.
DEFAULT
A default value can be specified to an attribute
CHECK
Use of check clause is to ensure that attribute values satisfy specified condition.
The entity integrity constraint states that primary keys can’t be null. There must be a
proper value in the primary key field. This is because the primary key value is used to
identify individual rows in a table. If there were null values for primary keys, it would
mean that we could not identify those rows. On the other hand, there can be null values
other than primary key fields. Null value means that one doesn’t know the value for that
field. Null value is different from zero value or space. The entity integrity constraints
assure that a specific row in a table can be identified.
For each entity set and relationship write a short description in plain English of
what it represents or models.
BOOKING DETAILS
)
create table Booking(
BID integer,
Bdate varchar(10),
Duration varchar(10),
Mplans varchar(10),
Fpayment varchar(10),
Rpayment varchar(10),
Mpayment varchar (10),
Apayment varchar(10),
GID integer,
primary key (BID),
foreign key (GID) references Guest(GID)
)
Figure 24 Log In
String sql = "insert into Guest (GID, fname, lname, DOB, NIC, TELno, GuestType)
values ('" + txtGuestID.Text + "','" + txtFname.Text + "','" + txtLname.Text + "','" +
txtDob.Text + "','" + txtNic.Text + "','" + txtTelno.Text + "','" + txtGuesttype.Text + "')";
SqlConnection con = new SqlConnection(c);
con.Open ();
SqlCommand cmd = new SqlCommand (sql, con);
cmd.ExecuteNonQuery ();
MessageBox.Show ("value is inserted successfully!!!");
con.Close ();
String sql = "update Guest set Fname ='" + txtFname.Text + "','" + txtLname.Text + "','"
+ txtDob.Text + "','" + txtNic.Text + "','" + txtTelno.Text + "','" + txtGuesttype.Text + "',
Where GID ='" + txtGuestID + "')";
SqlConnection con = new SqlConnection(c);
SqlCommand cmd = new SqlCommand (sql, con);
con.Open ();
cmd.ExecuteNonQuery ();
MessageBox.Show ("value is updated successfully!!!");
con.Close ();
Member Interface
String sql = "insert into Member (MID, fname, lname, DOB, NIC, GuestType) values ('"
+ txtMemberID.Text + "','" + txtFname.Text + "','" + txtLname.Text + "','" + txtDob.Text
+ "','" + txtNic.Text + "','" + txtGuesttype.Text + "')";
SqlConnection con = new SqlConnection(c);
con.Open ();
SqlCommand cmd = new SqlCommand (sql, con);
cmd.ExecuteNonQuery ();
MessageBox.Show ("value is inserted successfully!!!");
con.Close ();
Booking Interface
Facilities Interface
String sql = "insert into FACILITIES (FID, Ftype, Duration, Payment, GID) values ('" +
txtFID.Text + "','" + txtFtype.Text + "','" + txtDuration.Text + "','" +txtPayment.Text +
"','" + txtGID.Text + "'";
SqlConnection con = new SqlConnection(c);
con.Open ();
SqlCommand cmd = new SqlCommand (sql, con);
cmd.ExecuteNonQuery ();
MessageBox.Show ("value is inserted successfully!!!");
con.Close ()
string sql = "Update FACILITIES set Ftype ='" + txtFtype.Text + "','" + txtDuration.Text
+ "','" + txtPayment.Text + "','" + txtGID.Text + "' where FID='" + txtFID.Text + "'";
SqlConnection con = new SqlConnection(c);
SqlCommand cmd = new SqlCommand (sql, con);
con.Open ();
cmd.ExecuteNonQuery ();
MessageBox.Show ("value is updated successfully!!!");
con.Close ();
Room Interface
String sql = "insert into Room (RID, Btype, Price, Rtype, Views, BID) values ('" +
txtRID.Text + "','" + txtBtype.Text + "','" + txtPrice.Text + "','" + txtRtype.Text + "','" +
txtViews.Text + "','" + txtBID.Text + "')";
SqlConnection con = new SqlConnection(c);
con.Open ();
SqlCommand cmd = new SqlCommand (sql, con);
cmd.ExecuteNonQuery ();
MessageBox.Show ("value is inserted successfully!!!");
con.Close ();
TASK 3
3.1 Explain and provide evidence on the benefits gained when making use of DML
In a relational database system, it is considered as a database which appears to be nothing
more than a collection of tables, and it is based on three major aspects known as
structure, manipulation and integrity of data, whereas data manipulation is provided by a
set of algebraic or calculus operators, Data manipulation is known as a family of
computer languages which includes commands in permitting users to manipulate data in a
database. This kind of manipulation involves in inserting data into database tables, thus
retrieving existing data, deleting data from existing tables and modifying existing data.
Therefore DML is mostly incorporated in SQL databases. DML enhances efficient user
interaction with the system. Therefore the functional capability of DML is organized in
manipulation commands like SELECT, UPDATE, INSERT into and DELETE from as
mentioned below:
SELECT: This command is used to retrieve rows from a table. The syntax is
SELECT [column name(s)] from [table name] where [conditions]. SELECT is the
most widely used DML command in SQL.
UPDATE: This command modifies data of one or more records. An update command
syntax is UPDATE [table name] SET [column name = value] where [condition].
INSERT: This command adds one or more records to a database table. The insert
command syntax is INSERT INTO [table name] [column(s)] VALUES [value(s)].
DELETE: This command removes one or more records from a table according to
specified conditions. Delete command syntax is DELETE FROM [table name] where
[condition].
Source (www.techopedia.com, maria.db)
Queries are the primary mechanism for retrieving information from a database and
consist of questions presented to the database in a predefined format. Many database
management systems use the Structured Query Language (SQL) standard query format.
A database query is used to retrieve data from the database in a readable format
according to the user's request. There are some few advantages and there are as follows
Storage space
While you are developing a database that is entirely based on data specifications.
There are no unnecessary bytes or characters stored in the SQL database. This saves
storage space.
Database security
Security gets better because you can allow particular data to be stored in the SQL
database.
Speed
The database is efficient and uses the correct character length and data types, query
speed will improve.
3.2 Display the number of “Superior” rooms booked, facing “Garden” with “Twin
Beds”.
select count(RID)
from Room
where Views='Garden' and Btype='TwinBeds'
select * from Room
select *
from Facilities
where Ftype='prior'
Delete
from Room
where Rtype='Deluxe'
They have changed, by making storage, retrieval and accuracy of data that is stored more
efficiently effective and reliable. It enables us to execute arbitrary SQL commands.
The approach would be to select features that meet some criteria or that are located in a
particular place. We can build SQL queries to select particular features or rows from the
source data.
For example, the ‘Select’ tool allows us to use a SQL query to make a new feature class
of features that are selected from an existing class. As we specify about query tools, they
help analyze the data in a database in which they provide query building editing and
summarizes functionalities
Examples
The most basic SELECT statement has two parts. They are what columns you want to
return and what table those columns come from.
To retrieve all of the information about the entire Guest in the Add_New_Guest
table, we can use the asterisk (*) mark as a shortcut for all of the columns.
Figure 35 Guest/Member
Figure 36 Facilities/Guest
3.4 Provide suitable test cases and a test plan to test the database
Structural Testing
Functional Testing
Non-functional Testing
The structural data testing involves the validation of all those elements inside the data
repository that are used primarily for storage of data and which are not allowed to be
directly manipulated by the end users. The validation of the database servers is also a
very important consideration in these types of testing. The successful completion of this
phase by the testers involves mastery in SQL queries. It is also known as glass box
testing or white box testing, where it is an approach in which the tests are derived from
Schema testing
Database table, column testing
Keys and indexes testing
Stored procedures testing
Trigger testing
Functional Testing
The vice versa condition whereby first an operation is carried out by the tester at the user
interface and then the same is validated from the back end is also considered to be a valid
option.
The validations of the login and user security credentials need to take into consideration
the following things.
Whether the application prevents the user to proceed further in the application in case
of a
Invalid username but valid password
Valid username but invalid password.
Invalid username and invalid password.
Valid username and a valid password.
Non-functional testing
Risk quantification-
Quantification of risk actually helps the stakeholders to ascertain the various system
response time requirements under required levels of load. This is the original intent of
any quality assurance task. We need to note that load testing does not mitigate risk
directly, but through the processes of risk identification and of risk quantification,
presents corrective opportunities and an impetus for remediation that will mitigate
risk.
Description: Member Details form Adding Member, Update Member and Delete
Member
3 Display
Message
Delete
Records
2 Syntax Display
Errors Message
Object Display
3 Errors Error
Message
When you open MS Management Studio Express, a connection window with SQL Server
will be opened. In this window, enter the details for connection with SQL EXPRESS
existent in your PC. Click in the Server name box and choose the browser for more
option to search for the other server. You will have to use the Windows Authentication
mode to get access to the program.
After connected, the work area of Management Studio is then open. This window
presented the Menu Bar, Toolbar, Object Explorer and Active Files.
Through the Object Explorer section we can navigate among all of the Servers, Databases
and their items are contained (tables, views, Diagrams etc.).
The window for the new database is open. Then insert the database name, choose the
owner and configure the initial size of the log and data files. In the Options page, you can
set some of the new database’s advanced settings such as: Compatibility level, Recovery
model and containment type. After creating all the actions, click the OK button to create
the database.
Creating tables
To insert a field, you must write the name of the column, choose the data type and check
if it allow null values. After the new field selected, you will be able to set all its
properties in the Column Properties box. Set the primary key and save the table by
pressing CTRL+S. After the Management Studio Express asks you to enter the name of
the table .Once it is saved, the table begins to appear in the list of the Tables folder.
3.6 Verification
Verification in database is the procedure in checked properly so that data is entered
correctly into the database without any errors. When data gets move from one table to
other table or transcribe data in one format to other, there may be generate some errors
while entering data.
Validation
Validation is the procedure where we check the sensibility of data. There are a variety of
data validation methods and they are dependent on the data item. In the application
various fields and data are validated by providing the stored procedures, that only valid
data can be entered into database
There are many situations in which we need to do validation in our stored procedure. We
can do validation before update, delete and insert functions in stored procedures. Data
validation is the setting validation in a stored procedure on update, delete and insert
processes.
3.7 Triggers
A SQL trigger is a set of SQL statements stored in the database catalogue. A SQL trigger
is executed or fired whenever an event associated with a table occurs e.g., insert, update
or delete. A SQL trigger is a special type of stored procedure. It is special because it is
not called directly like a stored procedure. The main difference between a trigger and a
stored procedure is that a trigger is called automatically when a data modification event is
made against a table whereas a stored procedure must be called explicitly.
Source (www.mysqltutorial.org)
Types of Triggers
• There are three action query types that you use in SQL which are INSERT, UPDATE
and DELETE.
• So, there are three types of triggers and hybrids that come from mixing and matching
the events and timings that fire them.
• Instead Of Triggers
• These triggers run after an insert, update or delete on a table. They are not supported
for views.
I got to realize what a database is. I achieved many of the objectives which are mainly
data insertion, updating and deletion in the database and I learnt how to secure database
with the stored procedures and triggers. It’s certainly a new thing to us learning about
Databases.
The following system that we were given was Naomi Beach Villa Management System.
It gave me a wide knowledge about the relations designs on the database with entities
attributes and how to create a successful relation between each entity, and to give each a
valid unique primary key, plus also to make a difference between entity and attributes.
I'm very satisfied with this project as I achieved, and I gave my uttermost effort in
completing this following assignment.
We would be confused when everyone talks about it, mentioning about Databases and all
those stuff. But what is a Database. As we mention about Databases it is known as an
organized collection of data. It is the collection of schemas, tables, queries, reports, views
and other objects. Besides that, although we mentioned about Databases behind all that
it’s barely a design known as Database design.
Conclusion
Understanding different model of database and GUI applications; the knowledge behind
these models are effectively applied and database has been implemented as per the
requirements and regulations, SQL Server, SQL queries have been executed and the
results have been practical and reported. Also a GUI application related with the SQL
server is designed for the user to insert, update, delete and search data from the database.
In this way, all the given tasks have been successfully completed and are submitted with
proper documentation.
B M
BID, 57 MS, 74
D N
DAD, 92 NIC, 45
DBMS, 32
DDL, 45 O
DML, 73
OK, 94
DOB, 40, 65
P
E
PC, 74
ER, 45
ERD, 35
R
F RID, 57
FID, 55
S
G SET, 58
SQL, 92
GID, 65
GUI, 92
T
I TRIM, 68
IDE, 47
BID – Booking ID
FID – Facility ID
GID – Guest ID
RID – Room ID