Recall & Review
beginner
What is a column type in Flask-SQLAlchemy?
A column type defines the kind of data a column can hold, like Integer, String, or DateTime. It tells the database what type of information to expect.
Click to reveal answer
beginner
What does the
nullable=False constraint do in a column?It means the column cannot have empty or NULL values. Every row must have a value for that column.
Click to reveal answer
beginner
How do you set a column to be a primary key in Flask-SQLAlchemy?
You add
primary_key=True to the column definition. This makes the column unique and identifies each row.Click to reveal answer
beginner
What is the purpose of the
unique=True constraint?It ensures that all values in the column are different. No two rows can have the same value in that column.
Click to reveal answer
beginner
Name three common column types used in Flask-SQLAlchemy.
Common types include
Integer for numbers, String for text, and DateTime for date and time values.Click to reveal answer
Which column type would you use to store a person's name in Flask-SQLAlchemy?
✗ Incorrect
Names are text, so the String type is the right choice.
What does
primary_key=True do in a column definition?✗ Incorrect
Primary key uniquely identifies each row and cannot be NULL.
If you want to make sure no two users have the same email, which constraint should you use?
✗ Incorrect
unique=True ensures all values in the column are different.
What happens if you set
nullable=False on a column?✗ Incorrect
nullable=False means the column cannot be empty or NULL.
Which of these is NOT a valid column type in Flask-SQLAlchemy?
✗ Incorrect
ArrayList is not a column type in Flask-SQLAlchemy.
Explain how to define a column with a type and constraints in Flask-SQLAlchemy.
Think about how you tell the database what kind of data to expect and rules for that data.
You got /3 concepts.
Why are constraints like unique and nullable important when designing database columns?
Consider how rules help keep your data clean and trustworthy.
You got /4 concepts.