This document discusses the SQL statements used to create 8 tables for a medical database: Specialty, Doctor, Patient, Allergy, PatientAllergy, Appointment, Medicine, and PatientMedicine. It explains that constraints can be defined directly in a Create Table statement or by altering an existing table. It also notes that some databases use separate date and time data types while others allow them to be used together.
This document discusses the SQL statements used to create 8 tables for a medical database: Specialty, Doctor, Patient, Allergy, PatientAllergy, Appointment, Medicine, and PatientMedicine. It explains that constraints can be defined directly in a Create Table statement or by altering an existing table. It also notes that some databases use separate date and time data types while others allow them to be used together.
The following SQL statements are used to create the Specialty, Doctor, Patient, Allergy, PatientAllergy, Appointment, Medicine, and PatientMedicine tables.
As you can see Not Null constraints are added using the “Not Null” clause. We can define constraints in two ways: 1) A constraint can directly be defined in Create Table statement. 2) A constraint can be defined by altering an existing table with a constraint as in altering Doctor Table.
Using dates and times could be confusing in SQL. IBM DB2 and OpenOffice BASE use “date” and “time” data types separately. However, date and time could be used together with Oracle and Microsoft SQL Server.