Question

I have a "CustmerCrd" class that containing :

1.object of "Person" (another class) , let's call it per.
2.object of "Color" (enum type) , let's call it color.

My mission:

I had to create a DataBase table for this CustmerCrd class ,by using the "netbeans- create table dialog ". How do I do this?

my problem:

in the "Type" rubric (in the create table dialog) I have only the following types:

Date, TimeStamp, Boolean, Time, Decimal, Long varchacr, Char for bit data, VarChar for bit data, char, Real, Small int, BigInt, varChar, Blob, Double, integer, numeric, clob...

but i need "enum Color" type and "Person" type ,and of course it does not exist...

thank!

Was it helpful?

Solution

You cannot easily model this as one table as you have two classes i.e. CustomerCrd and Person. Therefore you need two tables, one for each with CustomerCrd having a person_id column that is a foreign key to the primary key of the corresponding row in the Person table. The Color enum can probably be collapsed into an int, but that is not particularly good practice as if the enum changes so might the meaning of the int values, better to create a 3rd table for the enumerations of the color and use a foreign key,

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top