Table Components Flashcards
What are some characteristics of a table?
It must contain at least one column, but it can contain zero rows.
Each column has to have a defined data type.
Columns can be set to allow or prevent null values.
What is a primary Key?
The Primary Key is a column or set of columns that makes a record unique in a table.
What is a Foreign Key?
A Foreign Key references the primary key in another table
Can a table have multiple Foreign Keys?
Yes!
Do the values need to be unique in a foreign key?
no
Do the values need to be unique in a primary key?
Yes
What is an Identity Column?
A numeric column that automatically increments when a new record is added to a table.
What is a NULL value?
An undefined value (not a blank value). Like a question that hasn’t been answered.
What is an exact numeric?
Its a data type like a bit, int, decimal, numeric, or money that stores numbers of various precision
What is a bit?
Can only can values like 1 or 0
What is an int?
Can only contain whole numbers (can be negative)
what is a decimal (p,s)
Can contain whole or decimal numbers. The p parameter specifies the total number of digits that the number can hold, and the s parameter specifies the number of digits to the right of the decimal point (scale).
How many decimal places can the decimal (p,s) go?
38
How many decimal places can the money numeric go?
4 decimal places
What is an approximate numeric?
Float and Real are approximate numerics. They are used when the precision of a number may exceed 38 places. They may not return an exact value.
What is the difference between float and real?
Real has a smaller range than float.
What is datetime2
Stores precise date and time
What is char (n)?
Stores fixed length character data like zip codes. Includes trailing spaces
What is varchar (n)
It stores character data as variable lengths.
What is varchar(max)
It stores large amounts of variable character data. Good for something like an essay.
What is nchar(n)?
It stores fixed length foreign character data. Like chinese characters.
What is nvarchar(n)?
It stores variable foreign character data lengths.
What is nvarchar(max)?
It stores large amounts of variable character data.
What is binary(n)?
Stores encrypted fixed-width data up to 8,000 bytes. The ‘n’ tells you how long. If the data is shorter than (n) length then it will be padded with zeros.