In today session we are going to explore the use of SQL (Structured Query Language) commands for creating tables and their relationships using primary and foreign keys. These operations can also be performed using SSMS object explorer. Here basic idea to learn these command is to interact with database systems using software’s or can say applications. We will learn here the use of GO statement while having multiple databases in our SQL Server using SQL server query language.
Related to the creation of tables and database this session will explore the basic data types that are used in SQL server. The use of identity and primary key. We can set the primary key using SQL command. We can execute multiple SQL statement in single query editor window with the help of semicolon. Each query is ended with semicolon. If we have only one query to be executed in query editor then there is no need to terminate the query with semicolon.
We use here Hospital Management System database example. In today video lecture we just create the following tables.
1. Doctor Table
2. Patient Table
In these two tables we create a reference for establishing foreign key. There is doctor_id foreign key in patient table. Patient table is treated as the child table.