MulaiMulai sekarang secara gratis

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).

Latihan ini adalah bagian dari kursus

Introduction to Relational Databases in SQL

Lihat Kursus

Petunjuk latihan

  • Given the above description of a student entity, create a table students with the correct column types.
  • Add a PRIMARY KEY for the social security number ssn.

Note that there is no formal length requirement for the integer column. The application would have to make sure it's a correct SSN!

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

-- Create the table
___ ___ students (
  last_name ___(___) ___ ___,
  ssn ___ ___,
  phone_no ___(___)
);
Edit dan Jalankan Kode