DBMS and RDBMS
Database Management System is a program that controls creation/maintenance/use of a database. RDBMS stores the data into the collection of tables, which is related by common fields between the columns of the table.

View
View is a saved query (table based on the result-set). A view always shows up-to-date data
CREATE VIEW [My new view] AS SELECT column1, column2 FROM myTable WHERE column1 = "value";
SELECT * FROM [My new view];
Update a view
CREATE OR REPLACE VIEW [My new view] AS SELECT...
Drop view
DROP VIEW [My new view];

SQL Injection
Input field accepts an malicious SQL statement.
1. 1=1 is Always True -> passwords
2. “”=”” is Always True
3. Batched SQL Statements -> 105; DROP TABLE Suppliers
A batch is a group of two or more statements, separated by semicolons.
Use parameters for protection:
string1 = “”string;
query = “INSERT INTO myTable (myColumn) Values(@0)”;
db.Execute(query, string1);

Normalization (Denormalization)
Process of minimizing redundancy and dependency by organizing fields into tables. Add/delete/modify a field that can be saved in a table.
There are 4 Normal Forms:

1NF (First Normal Form)

  • each cell to be single values
  • entries in columns to be same type
  • rows to be uniquely identified (add unique ID or add columns to make rows unique)

2NF

  • separating data into tables and creating relationships between these tables using, primary keys

3NF

  • removing columns that aren’t dependent on primary key

4NF

  • no multi-valued dependencies

Indices

  • clustered index
  • non-clustered index

Relationships

  • one to one relationship
  • one to many relationship
  • many to one relationship
  • self-referencing relationship