Database:
1 Create DatabaseTourvote;2 Create TableVotetheme3 (4ThemeidChar(Ten)Primary Key,5ThemeChar( +),6Votesumint 7 )8 Create TableTourism9 (TenTouridChar(Ten)Primary Key, OneTournameChar( -), AIntroductiontext , - Image Char( -), - ) the Create TableVoteresult - ( -ThemeidChar(Ten), -TouridChar(Ten), +Votenumint, -Voterateint, + Primary Key(Themeid,tourid), A Foreign Key(Themeid)ReferencesVotetheme (Themeid), at Foreign Key(Tourid)ReferencesTourism (tourid), - ) - Create TableAdmin - ( -IdChar(Ten)Primary Key, -NameChar(Ten), inPwdChar(Ten) -)
ALTER TABLE Voteresult
Add constraint
Votenum
Default 0 for Votenum;
Add constraint:
In the Voteresult
Check (Tourid in select Tourid from tourism)
Check (Themeid in select Themeid from Votetheme)
Foreign KEY (Themeid) references votetheme (themeid) on Delete on update
Foreign KEY (Tourid) references
1. Cascade, cascade operation. The primary table data is updated (the primary key value is updated), and the table is updated (foreign key value updates). The primary table record is deleted and the related records from the table are also deleted.
2. Set NULL, setting to NULL. The primary table data is updated (the primary key value is updated), and the foreign key from the table is set to NULL. The primary table record is deleted, and the foreign key from the table-related record is set to NULL. Note, however, that the foreign key column is required and there is no not NULL property constraint.
3. Restrict, reject parent table deletion and update.
ASP (C #) Tourist Attractions Online voting (i)