How do people make reusable databases that can be used for many products?
For example,if we have a database designed for a school...Can it be easily modified to be given to a college?
What is the way to create a database that can be used as a product to give solution to many customers with coding just once?
Thanks
An application such as this would require a fairly complex data model to account for the requirements. Different kinds of schools would have different requirements. A university might let you add or drop courses, but an elementary school typically does not. A university needs to schedule courses into rooms, whereas an elementary school needs to put students into grades and split grades into classrooms based on available space and teachers.
Your design needs to take into consideration all of the requirements it is expected to solve and then implement those. The more generic you make the program the harder it is to satisfy your customers. The question says "write the code once". If you want to write a single program that solves every school's needs, it will need hundreds of features; in some cases some schools will require an opposite feature from another school; for example some schools will need to enforce one teacher per subject or classroom while another school might require multiple teachers. The more requirements you expect to meet, the more complex the application becomes.
In industry big applications tend to be written so that they can be extended; a core set of functionality is provided but the application is meant to be changed and customized for a particular customer. This makes it easier to develop because you don't need to anticipate every need; in fact you won't need to anticipate many needs until you have a customer with those needs. But with "customization" you are not writing code only once.
The most important step is to come up with a data model that is flexible enough to extend later on, but isn't so flexible that it is impossible to develop for. The hardest part is usually getting the cardinality of relationships correct. For example, you might say a class has one teacher. Then when it turns out a class needs two teachers, you have to rewrite a lot of code and fix up a lot of data. These kinds of changes are annoying and time-consuming. However, in the end you can always fix mistakes given enough programmer time.