Introduction Flashcards
(19 cards)
What is SQL meaning?
Structured Query Language
How to select the id field from the users table?
SELECT id FROM users
Which languages use SQL?
SQLite, PostgreSQL, MySQL, Oracle
Which languages use NoSQL?
- MongoDB
- Redis
- ElasticSearch
Create the people table with the following fields:
id - Integer
name - Text
age - Integer
CREATE TABLE people (id INTEGER, name TEXT, age INTEGER)
How to rename table “employees” to “contractors”?
ALTER TABLE employees RENAME TO contractors;
How to rename column “salary” to “invoice” in table “employees”?
ALTER TABLE employees RENAME COLUMN salary TO invoice;
How to add column “job_title” of type TEXT to table “contractors”?
ALTER TABLE employees ADD COLUMN job_title TEXT;
How to delete column “is_manager” from table “contractors”?
ALTER TABLE employees DROP COLUMN is_manager
What is a migration?
A database migration is a set of changes to a relational database
Will database migrations often be coupled with application code updates?
YES
What DOWN migrations are necessary for?
For roll backs
They revert the UP migrations
How is a ‘true’ boolean value stored and presented in SQLite?
1
Which function is used to get the length of a TEXT column?
LENGTH
e.g. LENGTH(description)
What value takes a cell whose value is missing?
NULL
Is NULL value different from a zero value?
YES
What is a database constraint?
A constraint is a rule we create on a database that enforces some specific behavior.
Mention some of the most popular database constraints
- PRIMARY KEY
- NOT NULL
- UNIQUE
- FOREIGN KEY
What is a database schema?
A description of how data is organized within the database