kinda new to SQL, so need some help here. Firstly, please refer to the picture for my tables (BED table, WARD table, PATIENT table).
I am using Oracle SQL Developer Version 19.4.0.354 as a learning tool.
=====================================================================
EDIT: So i have changed the tables as like below:
BED(BEDNO, BED_OCCUPIEDDATE, WARDNO, PATIENTNO)
PATIENTS(PATIENTNO, FIRSTNAME, LASTNAME, ADDRESS, GENDER, DATEOFBIRTH, MARITALSTATUS, PHONENO, REGISTEREDDATE, WAITINGLISTDATE, EXPECTEDSTAY, DATEWARDED, EXPECTEDLEAVE, DATELEFT)
WARD(WARDNO, WARDNAME, LOCATION, NUMBEROFBED, EXTNO)
BedNo is unique in the entire database. numbered from 1-240. Meaning WardA will have bedno 1-10, WardB might have bedno 11-20 and so on.
How would i be able to allow allocation of patient to a ward only if there are bed available in the ward? Because currently, beds are not "tagged" to the ward if you refer to my ERD.