Test your knowledge before advancing
Before you move on to the next chapter, let's quickly review what you've learned so far about attributes and key constraints. If you're unsure about the answer, please quickly review chapters 2 and 3, respectively.
Let's think of an entity type "student". A student has:
- a last name consisting of up to 128 characters (required),
- a unique social security number, consisting only of integers, that should serve as a key,
- a phone number of fixed length 12, consisting of numbers and characters (but some students don't have one).
Deze oefening maakt deel uit van de cursus
Introduction to Relational Databases in SQL
Oefeninstructies
- Given the above description of a student entity, create a table
studentswith the correct column types. - Add a
PRIMARY KEYfor the social security numberssn.
Note that there is no formal length requirement for the integer column. The application would have to make sure it's a correct SSN!
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
-- Create the table
___ ___ students (
last_name ___(___) ___ ___,
ssn ___ ___,
phone_no ___(___)
);