CREATE TABLE estados
(
ibge numeric(7,0),
sigla character varying(2) NOT NULL,
nome character varying(50),
area numeric(15,5),
CONSTRAINT pk_estados PRIMARY KEY (sigla),
CONSTRAINT uq_estado_ibge UNIQUE (ibge)
)
CREATE TABLE municipios
(
ibge numeric(7,0) NOT NULL,
uf numeric(2,0),
nome character varying(50),
area numeric(15,5),
CONSTRAINT pk_municipio PRIMARY KEY (ibge),
CONSTRAINT fk_municipio_estado FOREIGN KEY (uf)
REFERENCES estados (ibge)
)
Considerando a linguagem de definição de dados e o código acima, que tem como objetivo criar duas relações estados e municípios, julgue os itens de 58 a 60.
(
ibge numeric(7,0),
sigla character varying(2) NOT NULL,
nome character varying(50),
area numeric(15,5),
CONSTRAINT pk_estados PRIMARY KEY (sigla),
CONSTRAINT uq_estado_ibge UNIQUE (ibge)
)
CREATE TABLE municipios
(
ibge numeric(7,0) NOT NULL,
uf numeric(2,0),
nome character varying(50),
area numeric(15,5),
CONSTRAINT pk_municipio PRIMARY KEY (ibge),
CONSTRAINT fk_municipio_estado FOREIGN KEY (uf)
REFERENCES estados (ibge)
)
Considerando a linguagem de definição de dados e o código acima, que tem como objetivo criar duas relações estados e municípios, julgue os itens de 58 a 60.
O código Java abaixo faz corretamente um mapeamento da classe Municipio com a tabela municipios, utilizando biblioteca de persistência, sem mapear o atributo area.
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table (name="municipios ")
public class Municipio implements Serializable {
@Id
private Long ibge;
private String nome;
public Long getIbge() {
return ibge;
}
public void setIbge (Long ibge) {
this.ibge = ibge;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
@JoinColumn(name="uf")
@ManyToOne
private Estado estado;
public Estado getEstado() {
return estado;
}
}
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table (name="municipios ")
public class Municipio implements Serializable {
@Id
private Long ibge;
private String nome;
public Long getIbge() {
return ibge;
}
public void setIbge (Long ibge) {
this.ibge = ibge;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
@JoinColumn(name="uf")
@ManyToOne
private Estado estado;
public Estado getEstado() {
return estado;
}
}
CertoErrado