即時製作一個數據庫系統,我想對有多少個座位是可用的。每部電影只能有100個座位。我該怎麼辦?如何創建一個sql限制
create table customer
(p_No int not null,
name varchar (30),
lastname varchar (30),
constraint p_No_pk primary key(p_No))
create table movie
(title varchar (500),
movie_No int not null,
seats int check(seats < 100),
date datetime,
primary key(movie_No))
create table ticket
(ticket_No int identity (1,1) not null,
movie_No int not null,
p_No int not null,
primary key(ticket_No),
foreign key(movie_No)
references movie (movie_No),
foreign key(p_No)
references customer(p_No))
100條記錄創建'ticket'表,並確保您的應用程序邏輯只修改那些記錄,但從不插入新的。添加一個表示座位是否可用的列。 –
[MySQL](https://dev.mysql.com/doc/)和[SQL Server](https://msdn.microsoft.com/en-us/library/ms130214.aspx)是由不同的產品提供的公司。他們以不同的方式實現和擴展標準的SQL。請標記您的問題與要使用的產品。 – axiac