A useful technique for your applications is to keep tuples of different types in the same schema. You can write your own graphical user interface (building on nxqddb) that only shows the relevant attributes for any given tuple.
For example, I may want a university database of students, faculty, and staff. They have some attributes in common, but some unique to the particular individual. And a few individuals may be both students and staff. A nice schema for this scenario might look something like the one shown in Figure 6.2.
Figure 6.2: A student/faculty/staff Schema
The question often arises whether you should use several relations or only one. In general, you should try to use only one relation unless you are planning to write a custom application. All the generic user interfaces deal with one relation at a time. Even so, Qddb is perfectly happy to deal with multiple relations if you are willing to program a custom application.
Generally speaking, the reasons to define multiple schemas are: (1) There is a many-to-many relationship among values in several relations, or (2) queries tend to search either one set of attributes or a different, disjoint set of attributes.
A good example is a customer-invoice database. You generally want to find a customer based on name, address, phone number, or customer identifier. You'd also like to be able to find a customer when you query an invoice number. When you generate a sales report, you will generally ignore the customer-identification data. In this case, the database can be logically divided into two pieces: the customer and the invoice.
Another example is the Library example from Chapter
2. If the same person is likely to borrow
multiple books, you may want to separate books and borrowers into two
relations. On the other hand, you can use a single relation with tuples that
either have the
Book attribute or the
non-empty. Each Book and each Borrower has a unique identifier.
Book attribute includes a list of borrower identifiers, and the
Borrower attribute includes a list of book identifiers.