Sqlite update select same table8/6/2023 ON DELETE CASCADE ON UPDATE NO ACTION Code language: SQL (Structured Query Language) ( sql ) FOREIGN KEY (group_id) Therefore, you use FOREIGN KEY constraint to define a foreign key for each column. In addition, the contact_id and group_id are the foreign keys. To add the table primary key constraint, you use this syntax: PRIMARY KEY (contact_id, group_id) Code language: SQL (Structured Query Language) ( sql ) The contact_groups table has a primary key that consists of two columns: contact_id and group_id. The following statement creates contact_groups table: CREATE TABLE contact_groups( The group_id column is the primary key column. The groups table is quite simple with two columns: group_id and name. The following statement creates the groups table: CREATE TABLE groups ( The email and phone are unique therefore we use the UNIQUE constraint for each column. It means that you must provide values when you insert or update rows in the contacts table. The first_name and last_name columns have TEXT storage class and these columns are NOT NULL. The contact_id is the primary key of the contacts table.īecause the primary key consists of one column, you can use the column constraint. ) Code language: SQL (Structured Query Language) ( sql ) The following statement creates the contacts table. The following database diagram illustrates tables: contacts groups, and contact_groups.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |