[英]mySQL how to make one field in table dependant on if some other field has a value?
im bulding a website using html/php/js/mysql 我使用html / php / js / mysql建立网站
I have a from on website where i need to enter Students ID and name of a course that student has passed, but some courses are dependant on other(example: i need to pass Calculus 1 before i can enter my Calculus 2 grade). 我在网站上有一个from站点,我需要输入学生ID和该学生已通过的课程的名称,但是有些课程取决于其他课程(例如:我需要通过Calculus 1才能进入我的Calculus 2成绩)。
I need to check that data usig AJAX(example: if i try to enter grade from Calculus 2, but Calculus 1 is not completed(no grade) i need to msg an error) and if all conditions are fulfilled then i proceed to enter data. 我需要检查数据是否使用AJAX(例如:如果我尝试从微积分2输入成绩,但微积分1尚未完成(没有成绩),我需要输入错误消息),如果所有条件都得到满足,那么我将继续输入数据。
What realy bugs me here: is there a way so i can make that kind of dependancy in mySQL? 有什么真正的问题困扰我:有没有办法让我可以在mySQL中进行这种依赖? (i want to make Calculus 2 dependant on Calculus 1 value). (我想使微积分2取决于微积分1的值)。
I hope that someone will understand my question and help me. 我希望有人能理解我的问题并为我提供帮助。 Thanks 谢谢
What you are asking is something that is supposed to be fulfilled by the logic of your program's code and not the SQL database. 您要问的是应该由程序代码的逻辑而非SQL数据库来实现的。 The database is only meant to store the data not doing logic based on said data. 该数据库仅用于存储不基于所述数据进行逻辑运算的数据。
The only kind of logic that SQL really does is transforming the data based on table aggregations or analyze data for patterns. SQL真正执行的唯一逻辑是基于表聚合转换数据或分析数据的模式。 It can do other stuff like force numbers in a certain table to never repeat. 它可以做其他事情,例如某个表中的强制编号,以永不重复。
Not allowing a table to have data unless another does is not part of the logic SQL handles. 不允许表具有数据,除非另一个表没有数据,这不是逻辑SQL句柄的一部分。 If you tell it to put data in a table then it will do it. 如果您告诉它将数据放在表中,那么它将完成该操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.