Database
Database
Relational Database
DDL - Data Definition Language
Table Creation
Attributes add
Define keys
DML - Data Manipulation Language
Manipulate Table
Update
Add
Remove
ER - Diagram:
erDiagram
student ||--o{ class : "has"
student {
string id
string name
int age
string classId
}
class {
string id
string description
}
Primary key:
unique
not null
SELECT name FROM student; -- Gives value of name column from table student
ORDER BY <col name> <asc/desc> (Arranges the data based on value of a column)
INSERT INTO <table_name> (<col1, col2, ...>) VALUES (<value1, value2, ...>)
UPDATE Student
SET phone_number = 9808076305
WHERE id = 1; -- Changes phone number of student with id 1
UPDATE Student
SET phone_number = 1; -- Changes phone number of all students to 1 (We get
error here!)
Functions
Must be in group
AVG(), COUNT(), MIN(), MAX()
ALTER TABLE