I have 2 tables
collection
==========
collection_id (primary key)
collection_name
collection_type
collectable
===========
collectable_id(primary key)
collectable_name
collectable_type
collectable_collection
What is the SQL statement so that collectable_collection can only take as input collection_id? Sorry if this is too simple. Is this a change specific to the column: collectable_collection or to the table: collectable?
I am using a MySQL database .
It’d be better if you implement this in the application level than with the SQL. Just check if the
idto be inserted in thecollectable_collectionis acollection_idand then perform the insert operation, if thecollectable_collectionhas more than onecollection_id‘s.EDIT
If the
collectable_collectionhas only one id in it, then you can useForeign Key. Check the manual, for more info on how to use it