Академический Документы
Профессиональный Документы
Культура Документы
The main purpose of the part 2 is to implement the database in an accurate manner. Therefore,
we need to DBMS software programs (Database management Systems) such as MySQL,
MSSQL and Oracle.
This part has three tasks. First, we need to show the SQL codes of the database. Then after
that, we have to write the CURD SQL functions. That means utilize the quires to insert data to
the above crated database.
Task 2.1 (Develop the Physical Database)
The primary purpose of this task is to develop the physical relational database in the DBMS
software programs. This database has been developed in MySQL and MSSQL. But the SQL
Coding are pretty much same in all DBMS. SQL is the general programming language for all
DBMS.
The main scope of this task is the SQL statements and functions. This task contains the
creation of the database tables in plain SQL codes.
The Customer table has two sub tables. One table contains information about the customers.
The other one contains the contact info about the customer. After that we link them together
using a foreign key.
Customer Table
Customer Contact Table
Note: Now we need to link the customer table with the customer_contact table. In order to do it
we need to use foreign key constraint.
Note: like We already mentioned most of the SQL codes are same in all DBMS. The customer
table, the contact details table and the ‘ALTER’ foreign keys SQL codes are pretty much same
in all DBMS. They work fine in MySQL, MSSQL and oracle databases.
Note: Bellow the outputs of the above SQL codes have been shown. The Physical Tables are
shown bellow in both DBMS MSSQL and MySQL.
Customer Table Design View in MSSQL
Note: The above tables are the output of the SQL codes that had been shown in the previous
page. These are the outputs in MSSQL.
Customer Table Design View in MySQL
Note: Like I already mentioned the SQL Codes are pretty much same in all DBMS. This the
MySQL version of the SQL codes.
2.1.2 Room Table (SQL Codes)
The Room table has been split into two tables since it is in the 3NF. The first table is the “rooms”
table that contains information about the rooms such as room Id and room type. The second
table is the “room_details” that contains basic fixed information such as room floor number and
room charge. Then we linked both of them using the foreign key. If it is hard to understand,
please refer the normalization part of the room table in the Part 01 section.
Room Table
The reservation table is the main component of the entire database. This has to be connect to
many sub tables such as customer and room. First, we need to create the table after that we
can create foreign keys to join between them.
Reservation Table
Now, we have come the critical section. The services table has many sub tables such as
newspaper, food&drink, cycle, map, theater and movies. We need to first write SQL codes for
sub tables then we can jump in the service table and link them via the foreign key constraint.
Note: Above all the sub products tables SQL codes have been shown such as Food&Drinks
table, newspaper table, map table, cycle table and movie and theater tables. Now we need to
write SQL codes of the service table. Then we can link the products from the sub products
tables to the service table using foreign key constraint. This concept has been already explained
well in the normalization part. Here We are converting the table into SQL language.
This is the main table that contains the service details of a gust. The service table divided into
two tables due to the normalization process. One table contains the information of the gust who
get the service such as customer id and room id and the service type that table is called
“Purchased info”. Another table contains information about the product id, quantity and service
charge this is the service table. First, we need to link the two tables together by using a foreign
key constraint. If it is confused, please refer the normalization process. This has been explained
clearly.
In Kingsbury hotel there are some major products and services that are shown above such as
Food&Drinks, newspaper, map, cycle and movie and theater. These are the services they
provide. Now we need to link them via using the foreign key constraint to services table. But the
service table will also need to link with the Purchased info table which contains information
about the customer. There are lots of connectivity among the services table since it is
normalized well. If it is confused, please refer the normalization process tables. Now we need to
convert the Purchased info table and the main service table into SQL codes.
Purchased info Table (SQL codes)
Like I already mentioned before. This table contains the purchasing details. We need to link this
table with many other tables such as customer table and room table, finally we will link this sub
table with the actual service table. But keep in mind this purchased info table is a one part of the
service table.
Purchased info Table customer id link with customer table customer id using foreign key
Purchased info Table room id link with room table room id using foreign key
Service Table (SQL codes)
Service Table Purchased_id link with Purchased table Purchased_id using foreign key
This one is the crucial one. Because we need to link all the product id such as newspaper, map,
food, cycle and movie with the services table as a foreign key.