I am using MySQL and I am creating a college event management database. In the database, I want to add a check constraint that prevents overlapping events when inserted into the events table. The problem I am having is that it seems like it will not allow an alias for the Events table so that I can compare the inserted row to all the other rows in the table. Is it not possible to use aliases in check constraints? ALTER TABLE Events As E ADD CONSTRAINT eventOverlap CHECK ((E.LocID=LocID) AND (E.Date=Date) AND ((End-E.Start) > 0) AND ((E.End-Start) > 0)) I have also tried using a select statement I get an error saying "Error Code: 3815. An expression of a check constraint 'eventOverlap' contains disallowed function." ALTER TABLE Events ADD Constraint eventOverlap CHECK ( NOT EXISTS (SELECT * FROM Events E WHERE E.LocID = LocID AND E.Date = Date AND ((E.Start <= Start AND E.End > Start) OR (E.Start < End AND E.End >= End)))) OR (E.Start < End AND E.End >= End)) ) );
I am using MySQL and I am creating a college event management
ALTER TABLE Events As E
ADD CONSTRAINT eventOverlap CHECK ((E.LocID=LocID) AND (E.Date=Date) AND ((End-E.Start) > 0) AND ((E.End-Start) > 0))
I have also tried using a select statement I get an error saying "Error Code: 3815. An expression of a check constraint 'eventOverlap' contains disallowed function."
ALTER TABLE Events
ADD Constraint eventOverlap CHECK (
NOT EXISTS
(SELECT * FROM Events E
WHERE E.LocID = LocID AND E.Date = Date AND
((E.Start <= Start AND E.End > Start)
OR (E.Start < End AND E.End >= End)))) OR (E.Start < End AND E.End >= End))
)
);
![SQL File 8* xrso
X
X
x
BZTA
1. ALTER TABLE Events
2
3
4
5
6
7
events
#
3
users
15
college-event.events
Limit to 1000 rows
ADD Constraint eventOverlap CHECK (
NOT EXISTS
(SELECT * FROM Events E
WHERE E.LOCID = LocID AND E.Date = Date AND
((E.Start <= Start AND E. End > Start)
OR (E.Start < End AND E.End >= End))))|
Output **************
0
Action Output
Time
Action
1 23:08:03 ALTER TABLE Events ADD CONSTRAINT eventOverlap CHECK ( NOT EXISTS ( SELECT * ...
2 23:20:56 ALTER TABLE Events ADD CHECK (NOT EXISTS (SELECT * FROM Events E WHERE E.LocID = Lo...
3 23:21:37 ALTER TABLE Events ADD Constraint eventOverlap CHECK (NOT EXISTS (SELECT FROM Events ...
191
SQLAdditions *****
► Ip
Jump to
Automatic context help i
disabled. Use the toolbar
manually get help for the
current caret position or
toggle automatic help.
> Context Help Snippets
Message
Error Code: 3815. An expression of a check constraint 'eventOverlap' contains disallowed function.
Error Code: 3815. An expression of a check constraint 'events_chk_2' contains disallowed function.
Error Code: 3815. An expression of a check constraint 'eventOverlap' contains disallowed function.
Duration / Fetch
0.063 sec
0.063 sec
0.000 sec](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fc1602b80-c5b7-44a0-838e-9b62644e132e%2Fa080714e-24e4-480f-9053-2857d5aa12bd%2Fd4se7r_processed.png&w=3840&q=75)
![SQL File 8* x
rso
events
users
college-event.events
14
TAUS
1 x ALTER TABLE Events As E
2
ADD CONSTRAINT eventOverlap CHECK ((E.LOCID=LOCID) AND (E.Date-Date) AND ((End-E.Start) > 0) AND ((E.End-Start) > 0))
53 Limit to 1000 rows
Q1](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fc1602b80-c5b7-44a0-838e-9b62644e132e%2Fa080714e-24e4-480f-9053-2857d5aa12bd%2Fmcnc6n_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
It still give the error:
Error Code: 3815. An expression of a check constraint 'eventOverlap' contains disallowed function.
![Oracle 12c: SQL](https://www.bartleby.com/isbn_cover_images/9781305251038/9781305251038_smallCoverImage.gif)
![Oracle 12c: SQL](https://www.bartleby.com/isbn_cover_images/9781305251038/9781305251038_smallCoverImage.gif)
![Programming with Microsoft Visual Basic 2017](https://www.bartleby.com/isbn_cover_images/9781337102124/9781337102124_smallCoverImage.gif)
![A Guide to SQL](https://www.bartleby.com/isbn_cover_images/9781111527273/9781111527273_smallCoverImage.gif)