2
Following the Object-Relational model, I want to create the tables or_medico
and or_atendente
derived from t_funcionario
that I created.
Below follows the structure of type:
DROP TYPE t_funcionario FORCE;
CREATE OR REPLACE TYPE t_funcionario AS OBJECT (
cod_func INTEGER,
nome_func VARCHAR2(50),
crm_med VARCHAR2(15),
escala_func VARCHAR2(12)
);
And the creative method of the tables or_medico
and or_atendente
DROP TABLE or_medico CASCADE CONSTRAINTS;
CREATE TABLE or_medico OF t_funcionario (
PRIMARY KEY (cod_func),
nome_func NOT NULL,
UNIQUE crm_med,
escala_func NOT NULL
) OBJECT IDENTIFIER IS SYSTEM GENERATED;
DROP TABLE or_atendente CASCADE CONSTRAINTS;
CREATE TABLE or_atendente OF t_funcionario (
PRIMARY KEY (cod_func),
nome_func NOT NULL,
escala_func NOT NULL
) OBJECT IDENTIFIER IS SYSTEM GENERATED;
In doing so, the attributes of both tables will end with "func", as they derive from t_funcionario
.
Would it be possible to change the name of the attributes so that they are specific to each table?
Example:
Table or_medico
has the attributes cod_med, nome_med, escala_med
and the table or_atendente
has the attributes cod_atendente, nome_atendente, escala_atendente
?
I believe that this cannot be done because the attribute of "type" will prevail but the creation of the table would already qualify , take the "func" of the primitive type and would be or_medico.name , however use "types" in database columns can make it impossible to query via sql in some languages on a front end. However your question is very interesting.
– Motta
@Motta, I asked the same question in Stackoverflow in English and I was told the same, that I could not change the name of the attribute, because the name coming from the type would prevail. I will answer this question with the link to my question in English.
– Luis Fernando