Results After Creating Foreign Key Constraints and Foreign Keys


Figure 3.31. Select Delete and Update mode

Results after creating primary key and foreign key constraints

Maybe you are interested!

Figure 3.32. The result after creating foreign key and foreign key constraints

- Delete foreign key constraint: Select foreign key constraint name/Select Delete/Select OK.

3) Unique constraints

- Create unique constraint:

Step 1: Select table name/Select Indexes/Select New Index.

Figure 3.33. Create unique constraint

Step 2: Enter the constraint name in the Index Name section/Select the Index type in the Index Type section/Check the Unique selection box/Select the Add button.


Figure 3.34. Enter a name for the unique constraint

Step 3: Select the check box in the field that needs to create a constraint/select OK/Select OK.

Figure 3.35. Select the field for which you want to create a unique constraint

Result after creating unique constraint

Figure 3.36. Unique constraint creation result

- Delete unique constraint: Select unique constraint name/Select Delete/Select OK.

4) Check constraints

- Create check constraint:


Step 1: Select table name/Select Constraints/Right click/Select New Constraints.

Figure 3.37. Create a check constraint

Step 2: Enter a name for the constraint in the Name section/ Select the … button in the Expression section.

Figure 3.38. Enter a name for the check constraint

Step 3: Enter constraint conditions/Select OK

Figure 3.39. Enter conditions for check constraints

Result after creating check constraint


Figure 3.40. Result of creating check constraint

- Delete check constraint: Select check constraint name/Select Delete/Select OK.

5) Default constraints

Select the field name for which you want to create a default constraint/Enter the default value in the Default Value or Binding section.

Figure 3.41. Create default constraints

Result after creating default constraint

Figure 3.42. Default constraint creation result

- Delete default constraint: Select default constraint name/Select Delete/Select OK.


3.2.3. Working with data tables

1) Connect the data tables

After successfully designing the data tables, we can create connections between the data tables.

Step 1: Select database/Select Database Diagrams/Select New Database Diagrams.

Figure 3.43. Creating connections between tables

Step 2: Select table/Select Add button. When you have selected the tables to create a connection, select Close button.

Figure 3.44. Select data tables

Step 3: Select the connection field of the first table and drag and drop it into the connection field of the second table.


Figure 3.45. Creating a connection

Step 4: Check the connection field/ Select OK.

Figure 3.46. Check connection field

Step 5: Confirm the connection/ Select OK. The connection between the tables is then created (Figure 3.30).

Figure 3.47. Confirming the connection


Figure 3.48. The connection is created.

Step 5: Save the connection. Select the Save button/Enter the connection name/OK.

Figure 3.49. Save connection

2) Change table structure

- Use MS tools

Step 1: Select database name/Select table name/Right click/Select Design.

Figure 3.50. Changing the structure of the data table

Step 2: Edit the table structure.

Figure 3.51. Redesigning the data table

Step 3: Select the Save button on the toolbar to save the changes. Select the Yes button to confirm the structure modification.


Figure 3.52. Confirming the data table redesign

- Use T-SQL statement

Step 1: Select the New Query button , the New Query window appears. Step 2: Declare the statement to change the data table structure (Alter Table). Step 3: Select the button to check the T-SQL statement.

Step 4: Select the button to execute the command to change the data table structure.

3) Clear table

- Use MS tools

Step 1: Select database name/Select table name/Right click/Select Delete.

Figure 3.53. Delete data table

Step 2: Select the OK button.

Comment


Agree Privacy Policy *