What values can a Boolean datatype hold?
True and false
What datatypes belong to the Character datatype?
char, varchar and text
What numeric datatypes exist?
smallint
integer
bigint
decimal
numeric
real
double precision
smallserial
serial
bigserial
What are temporal datatypes?
data, time, timestamp, and interval
What is the UUID datatype?
UUID stands for Universally unique identifier.
The UUID data type is considered a subtype of the STRING data type, because UUID values are displayed in their canonical textual format and, in general, behave the same as string values in the various SQL operators and expressions.
A UUID generated by the UUID() function would look like this:
UUID_VALUE1UUID_VALUE2UUID_VALUE3e762634c-3e41-11eb-b897-0862660ccbd4e7626367-3e41-11eb-b897-0862660ccbd4e7626368-3e41-11eb-b897-0862660ccbd4
What array datatypes are available in SQL?
Arrays can be used with many if not all? datatypes:
CREATE TABLE sal_emp (
name text,
pay_by_quarter integer[],
schedule text[][]
);
What is a Primary Key (PK)?
What does PK stand for?
Primary Key
What is a foreign key (FK)?
What does FK stand for?
Foreign Key
What is a referenced table or parent table?
A table to which the foreign key references is called referenced table or parent table
Can a table have multiple foreign keys?
Yes, depending on its relationships with other tables
What is a referencing table or child table?
The table that contains the foreign key is called referencing table or child table
What is a child table a child of?
And what does a child table have?
The parent table with the Primary Key
A child table has a foreign key, whereas a parent table has the primary key referencing to the child table
What is a constraint?
SQL constraints are used to specify rules for the data in a table.
Constraints are used to limit the type of data that can go into a table. This ensures the accuracy and reliability of the data in the table. If there is any violation between the constraint and the data action, the action is aborted.
Are constraints specified to a column or table?
Constraints can be column level or table level. Column-level constraints apply to a column, and table-level constraints apply to the whole table.
What are the most common constraints used in SQL
The following constraints are commonly used in SQL:
How can you create a table without any constraints or inheritance?
CREATE TABLE table_name (
column_name TYPE column_constraint,
column_name TYPE column_constraint,
);
What’s the best datatype for a Primary Key on Postgresql?
Serial
What’s the most commonly used datatype for Primary Keys in MySQL and SQL server etc?
Integer
How can you add a reference to a primary_key (foreign key (FK)) of a different table while creating a new table?
CREATE TABLE account_job(
user_id INTEGER REFERENCES account(user_id)
)
notice here that the data type for the user_id is not serial but INTEGER, the data type doesn’t need to be serial because we are only referencing the primary_key of another table.
What are things that you need to keep in mind when inserting row values into a table?
What does INSERT INTO do?
INSERT INTO is used for adding a row into a table.
What other command is used in combination with INSERT INTO?
INSERT INTO is used in combination with VALUES to specify values that will be inserted into the row