Dbms Lab 6 PDF
Dbms Lab 6 PDF
To create a database in the Microsoft SQL Server Management Studio, first open the software, open
the object explorer and connect it to the SQL server. After these steps, click the server name which is at the
top of the dialog box, after clicking this, a list of folders will appear, right click on databases folder and select
new database. A dialog box will appear and here, you can enter the name of your database, which is in this
case is ABC_Employees.
To create a table, do the steps dictated on the step 1, after that, click the database created and a list
of folders will appear below it, one of which is Tables, click the right click on the folder Tables and click new,
after it, click table. A window will appear (appearing as a new environment/tab), here, you can list the
attributes of the table you want to create and the data types on the second column, you can modify the
attribute if it will allow null values by checking the box on the 3rd column. The attributes, their corresponding
types and allowance of null is shown on the image above. To save this, enter Ctrl+s and a dialog box will
appear asking for the table name (dept_emp).
The same steps are done to create a new table (steps 1-2.1), the attributes, their corresponding
types and allowance of null values are shown above. As for setting a primary key on this table, right click on
the attribute from_date, click set primary key. To save this, enter Ctrl+s and a dialog box will appear asking
for the table name (salaries).
The same steps are done to create a new table (steps 1-2.1), the attributes, their corresponding
types and allowance of null values are shown above. As for setting a primary key on this table, right click on
the attribute dept_no, click set primary key. To save this, enter Ctrl+s and a dialog box will appear asking for
the table name (departments).
The same steps are done to create a new table (steps 1-2.1), the attributes, their corresponding
types and allowance of null values are shown above. As for setting a primary key on this table, right click on
the attribute emp_no, click set primary key. To save this, enter Ctrl+s and a dialog box will appear asking for
the table name (employees).
2.5 Create table dept_manager
The same steps are done to create a new table (steps 1-2.1), the attributes, their corresponding
types and allowance of null values are shown above. To save this, enter Ctrl+s and a dialog box will appear
asking for the table name (dept_manager).
The same steps are done to create a new table (steps 1-2.1), the attributes, their corresponding
types and allowance of null values are shown above. As for setting a primary key on this table, right click on
the attribute title, click set primary key. To save this, enter Ctrl+s and a dialog box will appear asking for the
table name (titles).
For the table dept_emp, 10 rows have been inserted with values in columns emp_no and dept_no
referenced to the primary keys emp_no and dept_no from tables employees and departments, respectively.
4.2 Insert values in table salaries
For the table salary, 10 rows have been inserted with values in column emp_no referenced to the
primary key emp_no from table employees. The primary key is from_date.
For the table department, 4 rows have been inserted since each employee is not necessarily limited
to a single department. (e.g. 3 employees can be in 1 department). The primary key is dept_no.
For the table employees, 10 rows have been inserted with columns birth_date and hire_date set to
null to show that how the allowance of null values in the process of creating a table works. The primary key
is emp_no.
4.5 Insert values in table dept_manager
For the table dept_manager, 4 rows have been inserted since usually, a single department has only
1 manager. As for the foreign keys, 4 rows have been inserted with values in columns emp_no and dept_no
referenced to the primary keys emp_no and dept_no from tables employees and departments, respectively.
For the table titles, 10 rows have been inserted since each employee has different titles. As for the
foreign key, 10 rows have been inserted with values in column emp_no referenced to the primary key emp_no
from table employees. The primary key is title.
5. Select and view the data in the tables of ABC_EmployeesDB database.
To select values in the created tables, right click on the table you want to select values from,
click Select Top 200 Rows, a new tab will open displaying the attributes of each table with values
below.
III. CONCLUSION
Using a third party software in creating databases is more efficient and time-saving
more than MySQL xampp since it is more visual and is easier to understand than hard coded
commands in command lines. This is due to the user-friendly nature of the software.
IV. RECOMMENDATIONS
Users are recommended to carefully create the tables and its attributes since the
mistakes are irredeemable, an error will occur if the user tries to rename an attribute referenced
from other tables.
V. LESSONS LEARNED
• The relationships created using the database diagram can be deleted and modified.
• Errors may occur if one tries to rename a referenced attribute.
• The protocol in connecting the object explorer in the SQL server is a little complicated,
sometimes the server name does not appear which requires the user to run through cmd
to retrieve it.