Subject | single or multi table |
---|---|
Author | Antonello Carlomagno |
Post date | 2001-08-07T22:56:15Z |
hi all,
I have this big doubt .
Must insert of information in a database several for a type, where every
type does not fill all the fields.
the structure should be this
TABLE1
NOME,COGNOME,INDIRIZZO
TABLE2
NOME,COGNOME,INDIRIZZO,EMAIL,URL
TABLE3
NOME,COGNOME,INDIRIZZO,DATA
And advisable create an only table containing all the records and do only a
SELECT.
SELECT NOME,COGNOME,INDIRIZZO,EMAIL,URL,DATA FROM TABELLA ORDER BY 1
or divide tables how many are the types and do SELECT UNION ALL
SELECT NOME,COGNOME,INDIRIZZO,cast (NULL as CHAR(30)) AS EMAIL,cast (NULL as
CHAR(30)) AS URL,cast (NULL as DATE) AS DATA FROM TIPO1
UNION ALL
SELECT NOME,COGNOME,INDIRIZZO,EMAIL,URL,cast (NULL as DATE) AS DATA FROM
TIPO2
UNION ALL
SELECT NOME,COGNOME,INDIRIZZO,cast (NULL as CHAR(30)) AS EMAIL,cast (NULL as
CHAR(30)) AS URL,DATA FROM TIPO3
ORDER BY 1
Concern the performances what system using is better ?
some suggestion ?
thanks for all Antonello
[Non-text portions of this message have been removed]
I have this big doubt .
Must insert of information in a database several for a type, where every
type does not fill all the fields.
the structure should be this
TABLE1
NOME,COGNOME,INDIRIZZO
TABLE2
NOME,COGNOME,INDIRIZZO,EMAIL,URL
TABLE3
NOME,COGNOME,INDIRIZZO,DATA
And advisable create an only table containing all the records and do only a
SELECT.
SELECT NOME,COGNOME,INDIRIZZO,EMAIL,URL,DATA FROM TABELLA ORDER BY 1
or divide tables how many are the types and do SELECT UNION ALL
SELECT NOME,COGNOME,INDIRIZZO,cast (NULL as CHAR(30)) AS EMAIL,cast (NULL as
CHAR(30)) AS URL,cast (NULL as DATE) AS DATA FROM TIPO1
UNION ALL
SELECT NOME,COGNOME,INDIRIZZO,EMAIL,URL,cast (NULL as DATE) AS DATA FROM
TIPO2
UNION ALL
SELECT NOME,COGNOME,INDIRIZZO,cast (NULL as CHAR(30)) AS EMAIL,cast (NULL as
CHAR(30)) AS URL,DATA FROM TIPO3
ORDER BY 1
Concern the performances what system using is better ?
some suggestion ?
thanks for all Antonello
[Non-text portions of this message have been removed]