Case study
In this case study, we will analyze the creation of a relational database for a simple bank checking account system.
To start structuring the database, we will perform the DDL of database creation and tables, with the proper types of data in each column, its primary keys, and indexes:
- The first sentence will create a database called
CRM
:CREATE DATABASE CRM;
- We continue to create the
Customers
table; in it, we will put the fields that will store the attributes of this client, which show the type of data in SQL, which of the fields cannot beNULL
, and the primary key:CREATE TABLE Customers( CustomerID int NOT NULL PRIMARY KEY, LastName varchar(255) NOT NULL, FirstName varchar(255) NOT NULL, FullAddress varchar(255), City varchar(255) );
- Now, let’s create an index in the
LastName
field of this table:CREATE INDEX idx_lastname ON Customers...