Skip to content

Latest commit

 

History

History
51 lines (40 loc) · 1.1 KB

File metadata and controls

51 lines (40 loc) · 1.1 KB

Data Structure

  • A relational database is an organization of related tables
  • A table consists of columns and rows
  • Each row represents an instance of an entity
  • Each column represents an attribute fo the entity instance

Note!
ALL FIELDS ARE NOT MADE THE SAME!

Data Type

  • The data type of a column defines what values the column can hold

Common Data Types

  • INT
  • VARCHAR
  • NVARCHAR
  • DATE
  • DATETIME
  • FLOAT
  • DOUBLE

Column Constraints

  • Specify rules for the data at the column level

Column Constraints

  • NULL or NOT NULL in each column
  • UNIQUE
  • PRIMARY KEY, FOREIGN KEY
  • DEFAULT

Data Constraint Example

CREATE TABLE Customer(
    CustomerID int(4) NOT NULL,
    FirstName nvarchar(50) NOT NULL,
    LastName nvarchar(50) NOT NULL,
    Email nvarchar(50) NULL,
    Phone nvarchar(50) NULL,
    Address nvarchar(50) NOT NULL,
    City nvarchar(50) NOT NULL,
    State nvarchar(50) NOT NULL,
    Zipcode int NOT NULL
)

Data Types

  • Data types ensure that the data is kept consistent