0
0
Flaskframework~5 mins

Column types and constraints in Flask - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AString
BInteger
CBoolean
DDateTime
What does primary_key=True do in a column definition?
AAllows NULL values
BSets a default value
CMakes the column optional
DMarks the column as unique and identifies each row
If you want to make sure no two users have the same email, which constraint should you use?
Anullable=False
Bunique=True
Cprimary_key=True
Ddefault='user@example.com'
What happens if you set nullable=False on a column?
AThe column is ignored by the database
BThe column can have empty values
CThe column must always have a value
DThe column automatically increments
Which of these is NOT a valid column type in Flask-SQLAlchemy?
AArrayList
BString
CInteger
DFloat
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.