brshare 0 Denunciar post Postado Novembro 3, 2006 ola pessoas estou modelando um banco de dados aqui e me deparei com uma duvida em relação a normalizacão de dados. Tenho uma tabela funcionarios, uma tabela clientes e uma tabela endereços, para este sistema, sabemos que um funcionario pode possuir 1 ou N enderecos e um cliente pode possuir 1 ou N enderecos. as tabelas funcionarios e clientes se relacionan com a tabela endereços. O problema é: como faço para relacionar estas tabelas, pois não posso migrar diretamente as chaves de funcionarios e clientes diretamente para endereços. Foi sugerido que eu criasse uma tabela enderecos_fun e enderecos_cli, so que assim eu estaria ferindo as formas normais, não seria?? para ficar mais claro o sistema estou disponibilizando o modelo feito no dbdesigner para quem o possui analisar esta relação: <?xml version="1.0" standalone="yes" ?> - <DBMODEL Version="4.0">- <SETTINGS> <GLOBALSETTINGS ModelName="model" IDModel="0" IDVersion="0" VersionStr="1.0.0.0" Comments="" UseVersionHistroy="1" AutoIncVersion="1" DatabaseType="MySQL" ZoomFac="100.00" XPos="2095" YPos="1045" DefaultDataType="5" DefaultTablePrefix="0" DefSaveDBConn="" DefSyncDBConn="" DefQueryDBConn="" Printer="" HPageCount="4.0" PageAspectRatio="1.440892512336408" PageOrientation="1" PageFormat="A4 (210x297 mm, 8.26x11.7 inches)" SelectedPages="" UsePositionGrid="0" PositionGridX="20" PositionGridY="20" TableNameInRefs="1" DefaultTableType="1" ActivateRefDefForNewRelations="1" FKPrefix="" FKPostfix="" CreateFKRefDefIndex="0" DBQuoteCharacter="`" CreateSQLforLinkedObjects="0" DefModelFont="Tahoma" CanvasWidth="4096" CanvasHeight="2842" /> - <DATATYPEGROUPS> <DATATYPEGROUP Name="Numeric Types" Icon="1" /> <DATATYPEGROUP Name="Date and Time Types" Icon="2" /> <DATATYPEGROUP Name="String Types" Icon="3" /> <DATATYPEGROUP Name="Blob and Text Types" Icon="4" /> <DATATYPEGROUP Name="User defined Types" Icon="5" /> <DATATYPEGROUP Name="Geographic Types" Icon="6" /> </DATATYPEGROUPS>- <DATATYPES>- <DATATYPE ID="1" IDGroup="0" TypeName="TINYINT" Description="A very small integer. The signed range is -128 to 127. The unsigned range is 0 to 255." ParamCount="1" OptionCount="2" ParamRequired="0" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="">- <PARAMS> <PARAM Name="length" /> </PARAMS>- <OPTIONS> <OPTION Name="UNSIGNED" Default="1" /> <OPTION Name="ZEROFILL" Default="0" /> </OPTIONS> </DATATYPE>- <DATATYPE ID="2" IDGroup="0" TypeName="SMALLINT" Description="A small integer. The signed range is -32768 to 32767. The unsigned range is 0 to 65535." ParamCount="1" OptionCount="2" ParamRequired="0" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="">- <PARAMS> <PARAM Name="length" /> </PARAMS>- <OPTIONS> <OPTION Name="UNSIGNED" Default="1" /> <OPTION Name="ZEROFILL" Default="0" /> </OPTIONS> </DATATYPE>- <DATATYPE ID="3" IDGroup="0" TypeName="MEDIUMINT" Description="A medium-size integer. The signed range is -8388608 to 8388607. The unsigned range is 0 to 16777215." ParamCount="1" OptionCount="2" ParamRequired="0" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="">- <PARAMS> <PARAM Name="length" /> </PARAMS>- <OPTIONS> <OPTION Name="UNSIGNED" Default="1" /> <OPTION Name="ZEROFILL" Default="0" /> </OPTIONS> </DATATYPE>- <DATATYPE ID="4" IDGroup="0" TypeName="INT" Description="A normal-size integer. The signed range is -2147483648 to 2147483647. The unsigned range is 0 to 4294967295." ParamCount="1" OptionCount="2" ParamRequired="0" EditParamsAsString="0" SynonymGroup="1" PhysicalMapping="0" PhysicalTypeName="">- <PARAMS> <PARAM Name="length" /> </PARAMS>- <OPTIONS> <OPTION Name="UNSIGNED" Default="0" /> <OPTION Name="ZEROFILL" Default="0" /> </OPTIONS> </DATATYPE>- <DATATYPE ID="5" IDGroup="0" TypeName="INTEGER" Description="A normal-size integer. The signed range is -2147483648 to 2147483647. The unsigned range is 0 to 4294967295." ParamCount="1" OptionCount="2" ParamRequired="0" EditParamsAsString="0" SynonymGroup="1" PhysicalMapping="0" PhysicalTypeName="">- <PARAMS> <PARAM Name="length" /> </PARAMS>- <OPTIONS> <OPTION Name="UNSIGNED" Default="1" /> <OPTION Name="ZEROFILL" Default="0" /> </OPTIONS> </DATATYPE>- <DATATYPE ID="6" IDGroup="0" TypeName="BIGINT" Description="A large integer. The signed range is -9223372036854775808 to 9223372036854775807. The unsigned range is 0 to 18446744073709551615." ParamCount="1" OptionCount="2" ParamRequired="0" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="">- <PARAMS> <PARAM Name="length" /> </PARAMS>- <OPTIONS> <OPTION Name="UNSIGNED" Default="0" /> <OPTION Name="ZEROFILL" Default="0" /> </OPTIONS> </DATATYPE>- <DATATYPE ID="7" IDGroup="0" TypeName="FLOAT" Description="A small (single-precision) floating-point number. Cannot be unsigned. Allowable values are -3.402823466E+38 to -1.175494351E-38, 0, and 1.175494351E-38 to 3.402823466E+38." ParamCount="1" OptionCount="1" ParamRequired="1" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="">- <PARAMS> <PARAM Name="precision" /> </PARAMS>- <OPTIONS> <OPTION Name="ZEROFILL" Default="0" /> </OPTIONS> </DATATYPE>- <DATATYPE ID="8" IDGroup="0" TypeName="FLOAT" Description="A small (single-precision) floating-point number. Cannot be unsigned. Allowable values are -3.402823466E+38 to -1.175494351E-38, 0, and 1.175494351E-38 to 3.402823466E+38." ParamCount="2" OptionCount="1" ParamRequired="0" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="">- <PARAMS> <PARAM Name="length" /> <PARAM Name="decimals" /> </PARAMS>- <OPTIONS> <OPTION Name="ZEROFILL" Default="0" /> </OPTIONS> </DATATYPE>- <DATATYPE ID="9" IDGroup="0" TypeName="DOUBLE" Description="A normal-size (double-precision) floating-point number. Cannot be unsigned. Allowable values are -1.7976931348623157E+308 to -2.2250738585072014E-308, 0, and 2.2250738585072014E-308 to 1.7976931348623157E+308." ParamCount="2" OptionCount="1" ParamRequired="0" EditParamsAsString="0" SynonymGroup="2" PhysicalMapping="0" PhysicalTypeName="">- <PARAMS> <PARAM Name="length" /> <PARAM Name="decimals" /> </PARAMS>- <OPTIONS> <OPTION Name="ZEROFILL" Default="0" /> </OPTIONS> </DATATYPE>- <DATATYPE ID="10" IDGroup="0" TypeName="DOUBLE PRECISION" Description="This is a synonym for DOUBLE." ParamCount="2" OptionCount="1" ParamRequired="0" EditParamsAsString="0" SynonymGroup="2" PhysicalMapping="0" PhysicalTypeName="">- <PARAMS> <PARAM Name="length" /> <PARAM Name="decimals" /> </PARAMS>- <OPTIONS> <OPTION Name="ZEROFILL" Default="0" /> </OPTIONS> </DATATYPE>- <DATATYPE ID="11" IDGroup="0" TypeName="REAL" Description="This is a synonym for DOUBLE." ParamCount="2" OptionCount="1" ParamRequired="0" EditParamsAsString="0" SynonymGroup="2" PhysicalMapping="0" PhysicalTypeName="">- <PARAMS> <PARAM Name="length" /> <PARAM Name="decimals" /> </PARAMS>- <OPTIONS> <OPTION Name="ZEROFILL" Default="0" /> </OPTIONS> </DATATYPE>- <DATATYPE ID="12" IDGroup="0" TypeName="DECIMAL" Description="An unpacked floating-point number. Cannot be unsigned. Behaves like a CHAR column." ParamCount="2" OptionCount="1" ParamRequired="0" EditParamsAsString="0" SynonymGroup="3" PhysicalMapping="0" PhysicalTypeName="">- <PARAMS> <PARAM Name="length" /> <PARAM Name="decimals" /> </PARAMS>- <OPTIONS> <OPTION Name="ZEROFILL" Default="0" /> </OPTIONS> </DATATYPE>- <DATATYPE ID="13" IDGroup="0" TypeName="NUMERIC" Description="This is a synonym for DECIMAL." ParamCount="2" OptionCount="1" ParamRequired="1" EditParamsAsString="0" SynonymGroup="3" PhysicalMapping="0" PhysicalTypeName="">- <PARAMS> <PARAM Name="length" /> <PARAM Name="decimals" /> </PARAMS>- <OPTIONS> <OPTION Name="ZEROFILL" Default="0" /> </OPTIONS> </DATATYPE> <DATATYPE ID="14" IDGroup="1" TypeName="DATE" Description="A date. The supported range is \a1000-01-01\a to \a9999-12-31\a." ParamCount="0" OptionCount="0" ParamRequired="0" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="" /> <DATATYPE ID="15" IDGroup="1" TypeName="DATETIME" Description="A date and time combination. The supported range is \a1000-01-01 00:00:00\a to \a9999-12-31 23:59:59\a." ParamCount="0" OptionCount="0" ParamRequired="0" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="" /> - <DATATYPE ID="16" IDGroup="1" TypeName="TIMESTAMP" Description="A timestamp. The range is \a1970-01-01 00:00:00\a to sometime in the year 2037. The length can be 14 (or missing), 12, 10, 8, 6, 4, or 2 representing YYYYMMDDHHMMSS, ... , YYYYMMDD, ... , YY formats." ParamCount="1" OptionCount="0" ParamRequired="0" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="">- <PARAMS> <PARAM Name="length" /> </PARAMS> </DATATYPE> <DATATYPE ID="17" IDGroup="1" TypeName="TIME" Description="A time. The range is \a-838:59:59\a to \a838:59:59\a." ParamCount="0" OptionCount="0" ParamRequired="0" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="" /> - <DATATYPE ID="18" IDGroup="1" TypeName="YEAR" Description="A year in 2- or 4-digit format (default is 4-digit)." ParamCount="1" OptionCount="0" ParamRequired="0" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="">- <PARAMS> <PARAM Name="length" /> </PARAMS> </DATATYPE>- <DATATYPE ID="19" IDGroup="2" TypeName="CHAR" Description="A fixed-length string (1 to 255 characters) that is always right-padded with spaces to the specified length when stored. values are sorted and compared in case-insensitive fashion according to the default character set unless the BINARY keyword is given." ParamCount="1" OptionCount="1" ParamRequired="1" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="">- <PARAMS> <PARAM Name="length" /> </PARAMS>- <OPTIONS> <OPTION Name="BINARY" Default="0" /> </OPTIONS> </DATATYPE>- <DATATYPE ID="20" IDGroup="2" TypeName="VARCHAR" Description="A variable-length string (1 to 255 characters). Values are sorted and compared in case-sensitive fashion unless the BINARY keyword is given." ParamCount="1" OptionCount="1" ParamRequired="1" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="">- <PARAMS> <PARAM Name="length" /> </PARAMS>- <OPTIONS> <OPTION Name="BINARY" Default="0" /> </OPTIONS> </DATATYPE> <DATATYPE ID="21" IDGroup="2" TypeName="BIT" Description="This is a synonym for CHAR(1)." ParamCount="0" OptionCount="0" ParamRequired="0" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="" /> <DATATYPE ID="22" IDGroup="2" TypeName="BOOL" Description="This is a synonym for CHAR(1)." ParamCount="0" OptionCount="0" ParamRequired="0" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="" /> <DATATYPE ID="23" IDGroup="3" TypeName="TINYBLOB" Description="A column maximum length of 255 (2^8 - 1) characters. Values are sorted and compared in case-sensitive fashion." ParamCount="0" OptionCount="0" ParamRequired="0" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="" /> <DATATYPE ID="24" IDGroup="3" TypeName="BLOB" Description="A column maximum length of 65535 (2^16 - 1) characters. Values are sorted and compared in case-sensitive fashion." ParamCount="0" OptionCount="0" ParamRequired="0" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="" /> <DATATYPE ID="25" IDGroup="3" TypeName="MEDIUMBLOB" Description="A column maximum length of 16777215 (2^24 - 1) characters. Values are sorted and compared in case-sensitive fashion." ParamCount="0" OptionCount="0" ParamRequired="0" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="" /> <DATATYPE ID="26" IDGroup="3" TypeName="LONGBLOB" Description="A column maximum length of 4294967295 (2^32 - 1) characters. Values are sorted and compared in case-sensitive fashion." ParamCount="0" OptionCount="0" ParamRequired="0" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="" /> <DATATYPE ID="27" IDGroup="3" TypeName="TINYTEXT" Description="A column maximum length of 255 (2^8 - 1) characters." ParamCount="0" OptionCount="0" ParamRequired="0" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="" /> <DATATYPE ID="28" IDGroup="3" TypeName="TEXT" Description="A column maximum length of 65535 (2^16 - 1) characters." ParamCount="0" OptionCount="0" ParamRequired="0" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="" /> <DATATYPE ID="29" IDGroup="3" TypeName="MEDIUMTEXT" Description="A column maximum length of 16777215 (2^24 - 1) characters." ParamCount="0" OptionCount="0" ParamRequired="0" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="" /> <DATATYPE ID="30" IDGroup="3" TypeName="LONGTEXT" Description="A column maximum length of 4294967295 (2^32 - 1) characters." ParamCount="0" OptionCount="0" ParamRequired="0" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="" /> - <DATATYPE ID="31" IDGroup="3" TypeName="ENUM" Description="An enumeration. A string object that can have only one value, chosen from the list of values." ParamCount="1" OptionCount="0" ParamRequired="1" EditParamsAsString="1" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="">- <PARAMS> <PARAM Name="values" /> </PARAMS> </DATATYPE>- <DATATYPE ID="32" IDGroup="3" TypeName="SET" Description="A set. A string object that can have zero or more values, each of which must be chosen from the list of values." ParamCount="1" OptionCount="0" ParamRequired="1" EditParamsAsString="1" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="">- <PARAMS> <PARAM Name="values" /> </PARAMS> </DATATYPE>- <DATATYPE ID="33" IDGroup="4" TypeName="Varchar(20)" Description="" ParamCount="0" OptionCount="1" ParamRequired="0" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="">- <OPTIONS> <OPTION Name="BINARY" Default="0" /> </OPTIONS> </DATATYPE>- <DATATYPE ID="34" IDGroup="4" TypeName="Varchar(45)" Description="" ParamCount="0" OptionCount="1" ParamRequired="0" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="">- <OPTIONS> <OPTION Name="BINARY" Default="0" /> </OPTIONS> </DATATYPE>- <DATATYPE ID="35" IDGroup="4" TypeName="Varchar(255)" Description="" ParamCount="0" OptionCount="1" ParamRequired="0" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="">- <OPTIONS> <OPTION Name="BINARY" Default="0" /> </OPTIONS> </DATATYPE> <DATATYPE ID="36" IDGroup="5" TypeName="GEOMETRY" Description="Geographic Datatype" ParamCount="0" OptionCount="0" ParamRequired="0" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="" /> <DATATYPE ID="38" IDGroup="5" TypeName="LINESTRING" Description="Geographic Datatype" ParamCount="0" OptionCount="0" ParamRequired="0" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="" /> <DATATYPE ID="39" IDGroup="5" TypeName="POLYGON" Description="Geographic Datatype" ParamCount="0" OptionCount="0" ParamRequired="0" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="" /> <DATATYPE ID="40" IDGroup="5" TypeName="MULTIPOINT" Description="Geographic Datatype" ParamCount="0" OptionCount="0" ParamRequired="0" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="" /> <DATATYPE ID="41" IDGroup="5" TypeName="MULTILINESTRING" Description="Geographic Datatype" ParamCount="0" OptionCount="0" ParamRequired="0" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="" /> <DATATYPE ID="42" IDGroup="5" TypeName="MULTIPOLYGON" Description="Geographic Datatype" ParamCount="0" OptionCount="0" ParamRequired="0" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="" /> <DATATYPE ID="43" IDGroup="5" TypeName="GEOMETRYCOLLECTION" Description="Geographic Datatype" ParamCount="0" OptionCount="0" ParamRequired="0" EditParamsAsString="0" SynonymGroup="0" PhysicalMapping="0" PhysicalTypeName="" /> </DATATYPES>- <COMMON_DATATYPES> <COMMON_DATATYPE ID="5" /> <COMMON_DATATYPE ID="8" /> <COMMON_DATATYPE ID="20" /> <COMMON_DATATYPE ID="15" /> <COMMON_DATATYPE ID="22" /> <COMMON_DATATYPE ID="28" /> <COMMON_DATATYPE ID="26" /> <COMMON_DATATYPE ID="33" /> <COMMON_DATATYPE ID="34" /> <COMMON_DATATYPE ID="35" /> </COMMON_DATATYPES>- <TABLEPREFIXES> <TABLEPREFIX Name="Default (no prefix)" /> </TABLEPREFIXES>- <REGIONCOLORS> <REGIONCOLOR Color="Red=#FFEEEC" /> <REGIONCOLOR Color="Yellow=#FEFDED" /> <REGIONCOLOR Color="Green=#EAFFE5" /> <REGIONCOLOR Color="Cyan=#ECFDFF" /> <REGIONCOLOR Color="Blue=#F0F1FE" /> <REGIONCOLOR Color="Magenta=#FFEBFA" /> </REGIONCOLORS>- <POSITIONMARKERS> <POSITIONMARKER ZoomFac="-1.0" X="0" Y="0" /> <POSITIONMARKER ZoomFac="-1.0" X="0" Y="0" /> <POSITIONMARKER ZoomFac="-1.0" X="0" Y="0" /> <POSITIONMARKER ZoomFac="-1.0" X="0" Y="0" /> <POSITIONMARKER ZoomFac="-1.0" X="0" Y="0" /> <POSITIONMARKER ZoomFac="-1.0" X="0" Y="0" /> <POSITIONMARKER ZoomFac="-1.0" X="0" Y="0" /> <POSITIONMARKER ZoomFac="-1.0" X="0" Y="0" /> <POSITIONMARKER ZoomFac="-1.0" X="0" Y="0" /> <POSITIONMARKER ZoomFac="-1.0" X="0" Y="0" /> <POSITIONMARKER ZoomFac="-1.0" X="0" Y="0" /> </POSITIONMARKERS> </SETTINGS>- <METADATA> <REGIONS /> - <TABLES>- <TABLE ID="1669" Tablename="produtos" PrevTableName="Table_01" XPos="1810" YPos="1317" TableType="1" TablePrefix="0" nmTable="0" Temporary="0" UseStandardInserts="0" StandardInserts="\n" TableOptions="DelayKeyTblUpdates=0\nPackKeys=0\nRowChecksum=0\nRowFormat=0\nUseRaid=0\nRaidType=0\n" Comments="" Collapsed="0" IsLinkedObject="0" IDLinkedModel="-1" Obj_id_Linked="-1" OrderPos="2">- <COLUMNS>- <COLUMN ID="1672" ColName="id_prod" PrevColName="" Pos="0" idDatatype="5" DatatypeParams="" Width="-1" Prec="-1" PrimaryKey="1" NotNull="1" AutoInc="1" IsForeignKey="0" DefaultValue="" Comments="">- <OPTIONSELECTED> <OPTIONSELECT Value="1" /> <OPTIONSELECT Value="0" /> </OPTIONSELECTED> </COLUMN>- <COLUMN ID="1689" ColName="nome" PrevColName="" Pos="1" idDatatype="20" DatatypeParams="(40)" Width="-1" Prec="-1" PrimaryKey="0" NotNull="0" AutoInc="0" IsForeignKey="0" DefaultValue="" Comments="">- <OPTIONSELECTED> <OPTIONSELECT Value="0" /> </OPTIONSELECTED> </COLUMN>- <COLUMN ID="1690" ColName="descricao" PrevColName="" Pos="2" idDatatype="20" DatatypeParams="(100)" Width="-1" Prec="-1" PrimaryKey="0" NotNull="0" AutoInc="0" IsForeignKey="0" DefaultValue="" Comments="">- <OPTIONSELECTED> <OPTIONSELECT Value="0" /> </OPTIONSELECTED> </COLUMN>- <COLUMN ID="1692" ColName="preco" PrevColName="" Pos="3" idDatatype="12" DatatypeParams="(6,2)" Width="-1" Prec="-1" PrimaryKey="0" NotNull="0" AutoInc="0" IsForeignKey="0" DefaultValue="" Comments="">- <OPTIONSELECTED> <OPTIONSELECT Value="0" /> </OPTIONSELECTED> </COLUMN> </COLUMNS>- <RELATIONS_START> <RELATION_START ID="1679" /> </RELATIONS_START>- <INDICES>- <INDEX ID="1673" IndexName="PRIMARY" IndexKind="0" FKRefDef_Obj_id="-1">- <INDEXCOLUMNS> <INDEXCOLUMN idColumn="1672" LengthParam="0" /> </INDEXCOLUMNS> </INDEX> </INDICES> </TABLE>- <TABLE ID="1674" Tablename="vendas" PrevTableName="Table_02" XPos="2278" YPos="1249" TableType="1" TablePrefix="0" nmTable="0" Temporary="0" UseStandardInserts="0" StandardInserts="\n" TableOptions="DelayKeyTblUpdates=0\nPackKeys=0\nRowChecksum=0\nRowFormat=0\nUseRaid=0\nRaidType=0\n" Comments="" Collapsed="0" IsLinkedObject="0" IDLinkedModel="-1" Obj_id_Linked="-1" OrderPos="3">- <COLUMNS>- <COLUMN ID="1676" ColName="id_vend" PrevColName="" Pos="0" idDatatype="5" DatatypeParams="" Width="-1" Prec="-1" PrimaryKey="1" NotNull="1" AutoInc="1" IsForeignKey="0" DefaultValue="" Comments="">- <OPTIONSELECTED> <OPTIONSELECT Value="1" /> <OPTIONSELECT Value="0" /> </OPTIONSELECTED> </COLUMN>- <COLUMN ID="1700" ColName="id_cli" PrevColName="" Pos="1" idDatatype="5" DatatypeParams="" Width="-1" Prec="-1" PrimaryKey="1" NotNull="1" AutoInc="0" IsForeignKey="1" DefaultValue="" Comments="">- <OPTIONSELECTED> <OPTIONSELECT Value="1" /> <OPTIONSELECT Value="0" /> </OPTIONSELECTED> </COLUMN>- <COLUMN ID="1731" ColName="id_fun" PrevColName="" Pos="1" idDatatype="5" DatatypeParams="" Width="-1" Prec="-1" PrimaryKey="1" NotNull="1" AutoInc="0" IsForeignKey="1" DefaultValue="" Comments="">- <OPTIONSELECTED> <OPTIONSELECT Value="1" /> <OPTIONSELECT Value="0" /> </OPTIONSELECTED> </COLUMN> </COLUMNS>- <RELATIONS_START> <RELATION_START ID="1680" /> </RELATIONS_START>- <RELATIONS_END> <RELATION_END ID="1698" /> <RELATION_END ID="1729" /> </RELATIONS_END>- <INDICES>- <INDEX ID="1677" IndexName="PRIMARY" IndexKind="0" FKRefDef_Obj_id="-1">- <INDEXCOLUMNS> <INDEXCOLUMN idColumn="1676" LengthParam="0" /> <INDEXCOLUMN idColumn="1700" LengthParam="0" /> <INDEXCOLUMN idColumn="1731" LengthParam="0" /> </INDEXCOLUMNS> </INDEX> </INDICES> </TABLE>- <TABLE ID="1678" Tablename="itens_venda" PrevTableName="produtos_has_vendas" XPos="2042" YPos="1393" TableType="1" TablePrefix="0" nmTable="1" Temporary="0" UseStandardInserts="0" StandardInserts="\n" TableOptions="DelayKeyTblUpdates=0\nPackKeys=0\nRowChecksum=0\nRowFormat=0\nUseRaid=0\nRaidType=0\n" Comments="" Collapsed="0" IsLinkedObject="0" IDLinkedModel="-1" Obj_id_Linked="-1" OrderPos="4">- <COLUMNS>- <COLUMN ID="1685" ColName="id_prod" PrevColName="" Pos="1" idDatatype="5" DatatypeParams="" Width="-1" Prec="-1" PrimaryKey="1" NotNull="1" AutoInc="0" IsForeignKey="1" DefaultValue="" Comments="">- <OPTIONSELECTED> <OPTIONSELECT Value="1" /> <OPTIONSELECT Value="0" /> </OPTIONSELECTED> </COLUMN>- <COLUMN ID="1686" ColName="id_vend" PrevColName="" Pos="1" idDatatype="5" DatatypeParams="" Width="-1" Prec="-1" PrimaryKey="1" NotNull="1" AutoInc="0" IsForeignKey="1" DefaultValue="" Comments="">- <OPTIONSELECTED> <OPTIONSELECT Value="1" /> <OPTIONSELECT Value="0" /> </OPTIONSELECTED> </COLUMN>- <COLUMN ID="1706" ColName="vendas_id_cli" PrevColName="" Pos="1" idDatatype="5" DatatypeParams="" Width="-1" Prec="-1" PrimaryKey="1" NotNull="1" AutoInc="0" IsForeignKey="1" DefaultValue="" Comments="">- <OPTIONSELECTED> <OPTIONSELECT Value="1" /> <OPTIONSELECT Value="0" /> </OPTIONSELECTED> </COLUMN>- <COLUMN ID="1737" ColName="vendas_id_fun" PrevColName="" Pos="1" idDatatype="5" DatatypeParams="" Width="-1" Prec="-1" PrimaryKey="1" NotNull="1" AutoInc="0" IsForeignKey="1" DefaultValue="" Comments="">- <OPTIONSELECTED> <OPTIONSELECT Value="1" /> <OPTIONSELECT Value="0" /> </OPTIONSELECTED> </COLUMN> </COLUMNS>- <RELATIONS_END> <RELATION_END ID="1679" /> <RELATION_END ID="1680" /> </RELATIONS_END>- <INDICES>- <INDEX ID="1683" IndexName="PRIMARY" IndexKind="0" FKRefDef_Obj_id="-1">- <INDEXCOLUMNS> <INDEXCOLUMN idColumn="1685" LengthParam="0" /> <INDEXCOLUMN idColumn="1686" LengthParam="0" /> <INDEXCOLUMN idColumn="1706" LengthParam="0" /> <INDEXCOLUMN idColumn="1737" LengthParam="0" /> </INDEXCOLUMNS> </INDEX> </INDICES> </TABLE>- <TABLE ID="1694" Tablename="clientes" PrevTableName="Table_04" XPos="2580" YPos="1397" TableType="1" TablePrefix="0" nmTable="0" Temporary="0" UseStandardInserts="0" StandardInserts="\n" TableOptions="DelayKeyTblUpdates=0\nPackKeys=0\nRowChecksum=0\nRowFormat=0\nUseRaid=0\nRaidType=0\n" Comments="" Collapsed="0" IsLinkedObject="0" IDLinkedModel="-1" Obj_id_Linked="-1" OrderPos="7">- <COLUMNS>- <COLUMN ID="1696" ColName="id_cli" PrevColName="" Pos="0" idDatatype="5" DatatypeParams="" Width="-1" Prec="-1" PrimaryKey="1" NotNull="1" AutoInc="1" IsForeignKey="0" DefaultValue="" Comments="">- <OPTIONSELECTED> <OPTIONSELECT Value="1" /> <OPTIONSELECT Value="0" /> </OPTIONSELECTED> </COLUMN> </COLUMNS>- <RELATIONS_START> <RELATION_START ID="1698" /> <RELATION_START ID="1715" /> </RELATIONS_START>- <INDICES>- <INDEX ID="1697" IndexName="PRIMARY" IndexKind="0" FKRefDef_Obj_id="-1">- <INDEXCOLUMNS> <INDEXCOLUMN idColumn="1696" LengthParam="0" /> </INDEXCOLUMNS> </INDEX> </INDICES> </TABLE>- <TABLE ID="1711" Tablename="telefones" PrevTableName="Table_06" XPos="2680" YPos="1578" TableType="1" TablePrefix="0" nmTable="0" Temporary="0" UseStandardInserts="0" StandardInserts="\n" TableOptions="DelayKeyTblUpdates=0\nPackKeys=0\nRowChecksum=0\nRowFormat=0\nUseRaid=0\nRaidType=0\n" Comments="" Collapsed="0" IsLinkedObject="0" IDLinkedModel="-1" Obj_id_Linked="-1" OrderPos="11">- <COLUMNS>- <COLUMN ID="1713" ColName="id_tel" PrevColName="" Pos="0" idDatatype="5" DatatypeParams="" Width="-1" Prec="-1" PrimaryKey="1" NotNull="1" AutoInc="1" IsForeignKey="0" DefaultValue="" Comments="">- <OPTIONSELECTED> <OPTIONSELECT Value="1" /> <OPTIONSELECT Value="0" /> </OPTIONSELECTED> </COLUMN>- <COLUMN ID="1717" ColName="id_cli" PrevColName="" Pos="1" idDatatype="5" DatatypeParams="" Width="-1" Prec="-1" PrimaryKey="0" NotNull="1" AutoInc="0" IsForeignKey="1" DefaultValue="" Comments="">- <OPTIONSELECTED> <OPTIONSELECT Value="1" /> <OPTIONSELECT Value="0" /> </OPTIONSELECTED> </COLUMN> </COLUMNS>- <RELATIONS_END> <RELATION_END ID="1715" /> </RELATIONS_END>- <INDICES>- <INDEX ID="1714" IndexName="PRIMARY" IndexKind="0" FKRefDef_Obj_id="-1">- <INDEXCOLUMNS> <INDEXCOLUMN idColumn="1713" LengthParam="0" /> </INDEXCOLUMNS> </INDEX> </INDICES> </TABLE>- <TABLE ID="1718" Tablename="funcionarios" PrevTableName="Table_07" XPos="2290" YPos="1087" TableType="1" TablePrefix="0" nmTable="0" Temporary="0" UseStandardInserts="0" StandardInserts="\n" TableOptions="DelayKeyTblUpdates=0\nPackKeys=0\nRowChecksum=0\nRowFormat=0\nUseRaid=0\nRaidType=0\n" Comments="" Collapsed="0" IsLinkedObject="0" IDLinkedModel="-1" Obj_id_Linked="-1" OrderPos="13">- <COLUMNS>- <COLUMN ID="1723" ColName="id_fun" PrevColName="" Pos="0" idDatatype="5" DatatypeParams="" Width="-1" Prec="-1" PrimaryKey="1" NotNull="1" AutoInc="1" IsForeignKey="0" DefaultValue="" Comments="">- <OPTIONSELECTED> <OPTIONSELECT Value="1" /> <OPTIONSELECT Value="0" /> </OPTIONSELECTED> </COLUMN> </COLUMNS>- <RELATIONS_START> <RELATION_START ID="1729" /> </RELATIONS_START>- <INDICES>- <INDEX ID="1724" IndexName="PRIMARY" IndexKind="0" FKRefDef_Obj_id="-1">- <INDEXCOLUMNS> <INDEXCOLUMN idColumn="1723" LengthParam="0" /> </INDEXCOLUMNS> </INDEX> </INDICES> </TABLE>- <TABLE ID="1738" Tablename="enderecos" PrevTableName="Table_09" XPos="2600" YPos="1064" TableType="1" TablePrefix="0" nmTable="0" Temporary="0" UseStandardInserts="0" StandardInserts="\n" TableOptions="DelayKeyTblUpdates=0\nPackKeys=0\nRowChecksum=0\nRowFormat=0\nUseRaid=0\nRaidType=0\n" Comments="" Collapsed="0" IsLinkedObject="0" IDLinkedModel="-1" Obj_id_Linked="-1" OrderPos="13">- <COLUMNS>- <COLUMN ID="1740" ColName="id_end" PrevColName="" Pos="0" idDatatype="5" DatatypeParams="" Width="-1" Prec="-1" PrimaryKey="1" NotNull="1" AutoInc="1" IsForeignKey="0" DefaultValue="" Comments="">- <OPTIONSELECTED> <OPTIONSELECT Value="1" /> <OPTIONSELECT Value="0" /> </OPTIONSELECTED> </COLUMN>- <COLUMN ID="1750" ColName="id_tipo" PrevColName="" Pos="1" idDatatype="5" DatatypeParams="" Width="-1" Prec="-1" PrimaryKey="1" NotNull="1" AutoInc="0" IsForeignKey="1" DefaultValue="" Comments="">- <OPTIONSELECTED> <OPTIONSELECT Value="1" /> <OPTIONSELECT Value="0" /> </OPTIONSELECTED> </COLUMN> </COLUMNS>- <RELATIONS_END> <RELATION_END ID="1748" /> </RELATIONS_END>- <INDICES>- <INDEX ID="1741" IndexName="PRIMARY" IndexKind="0" FKRefDef_Obj_id="-1">- <INDEXCOLUMNS> <INDEXCOLUMN idColumn="1740" LengthParam="0" /> <INDEXCOLUMN idColumn="1750" LengthParam="0" /> </INDEXCOLUMNS> </INDEX> </INDICES> </TABLE>- <TABLE ID="1742" Tablename="tipoend" PrevTableName="Table_10" XPos="2613" YPos="1202" TableType="1" TablePrefix="0" nmTable="0" Temporary="0" UseStandardInserts="0" StandardInserts="\n" TableOptions="DelayKeyTblUpdates=0\nPackKeys=0\nRowChecksum=0\nRowFormat=0\nUseRaid=0\nRaidType=0\n" Comments="" Collapsed="0" IsLinkedObject="0" IDLinkedModel="-1" Obj_id_Linked="-1" OrderPos="14">- <COLUMNS>- <COLUMN ID="1746" ColName="id_tipo" PrevColName="" Pos="0" idDatatype="5" DatatypeParams="" Width="-1" Prec="-1" PrimaryKey="1" NotNull="1" AutoInc="1" IsForeignKey="0" DefaultValue="" Comments="">- <OPTIONSELECTED> <OPTIONSELECT Value="1" /> <OPTIONSELECT Value="0" /> </OPTIONSELECTED> </COLUMN> </COLUMNS>- <RELATIONS_START> <RELATION_START ID="1748" /> </RELATIONS_START>- <INDICES>- <INDEX ID="1747" IndexName="PRIMARY" IndexKind="0" FKRefDef_Obj_id="-1">- <INDEXCOLUMNS> <INDEXCOLUMN idColumn="1746" LengthParam="0" /> </INDEXCOLUMNS> </INDEX> </INDICES> </TABLE> </TABLES>- <RELATIONS> <RELATION ID="1679" RelationName="Rel_01" Kind="1" SrcTable="1669" DestTable="1678" FKFields="id_prod=id_prod\n" FKFieldsComments="\n" relDirection="2" MidOffset="0" OptionalStart="0" OptionalEnd="0" CaptionOffsetX="0" CaptionOffsetY="0" StartIntervalOffsetX="0" StartIntervalOffsetY="0" EndIntervalOffsetX="0" EndIntervalOffsetY="0" CreateRefDef="1" Invisible="0" RefDef="Matching=0\nOnDelete=3\nOnUpdate=3\n" Comments="" FKRefDefIndex_Obj_id="-1" Splitted="0" IsLinkedObject="0" IDLinkedModel="-1" Obj_id_Linked="-1" OrderPos="5" /> <RELATION ID="1680" RelationName="Rel_02" Kind="1" SrcTable="1674" DestTable="1678" FKFields="id_vend=id_vend\nid_cli=vendas_id_cli\nid_fun=vendas_id_fun\n" FKFieldsComments="\n\n\n" relDirection="4" MidOffset="0" OptionalStart="0" OptionalEnd="0" CaptionOffsetX="0" CaptionOffsetY="0" StartIntervalOffsetX="0" StartIntervalOffsetY="0" EndIntervalOffsetX="0" EndIntervalOffsetY="0" CreateRefDef="1" Invisible="0" RefDef="Matching=0\nOnDelete=3\nOnUpdate=3\n" Comments="" FKRefDefIndex_Obj_id="-1" Splitted="0" IsLinkedObject="0" IDLinkedModel="-1" Obj_id_Linked="-1" OrderPos="6" /> <RELATION ID="1698" RelationName="Rel_03" Kind="1" SrcTable="1694" DestTable="1674" FKFields="id_cli=id_cli\n" FKFieldsComments="\n" relDirection="4" MidOffset="0" OptionalStart="0" OptionalEnd="0" CaptionOffsetX="0" CaptionOffsetY="0" StartIntervalOffsetX="0" StartIntervalOffsetY="0" EndIntervalOffsetX="0" EndIntervalOffsetY="0" CreateRefDef="1" Invisible="0" RefDef="Matching=0\nOnDelete=3\nOnUpdate=3\n" Comments="" FKRefDefIndex_Obj_id="-1" Splitted="0" IsLinkedObject="0" IDLinkedModel="-1" Obj_id_Linked="-1" OrderPos="8" /> <RELATION ID="1715" RelationName="Rel_05" Kind="2" SrcTable="1694" DestTable="1711" FKFields="id_cli=id_cli\n" FKFieldsComments="\n" relDirection="3" MidOffset="0" OptionalStart="0" OptionalEnd="0" CaptionOffsetX="0" CaptionOffsetY="0" StartIntervalOffsetX="0" StartIntervalOffsetY="0" EndIntervalOffsetX="0" EndIntervalOffsetY="0" CreateRefDef="1" Invisible="0" RefDef="Matching=0\nOnDelete=3\nOnUpdate=3\n" Comments="" FKRefDefIndex_Obj_id="-1" Splitted="0" IsLinkedObject="0" IDLinkedModel="-1" Obj_id_Linked="-1" OrderPos="12" /> <RELATION ID="1729" RelationName="Rel_08" Kind="1" SrcTable="1718" DestTable="1674" FKFields="id_fun=id_fun\n" FKFieldsComments="\n" relDirection="3" MidOffset="0" OptionalStart="0" OptionalEnd="0" CaptionOffsetX="0" CaptionOffsetY="0" StartIntervalOffsetX="0" StartIntervalOffsetY="0" EndIntervalOffsetX="0" EndIntervalOffsetY="0" CreateRefDef="1" Invisible="0" RefDef="Matching=0\nOnDelete=3\nOnUpdate=3\n" Comments="" FKRefDefIndex_Obj_id="-1" Splitted="0" IsLinkedObject="0" IDLinkedModel="-1" Obj_id_Linked="-1" OrderPos="14" /> <RELATION ID="1748" RelationName="Rel_09" Kind="4" SrcTable="1742" DestTable="1738" FKFields="id_tipo=id_tipo\n" FKFieldsComments="\n" relDirection="1" MidOffset="0" OptionalStart="0" OptionalEnd="0" CaptionOffsetX="0" CaptionOffsetY="0" StartIntervalOffsetX="0" StartIntervalOffsetY="0" EndIntervalOffsetX="0" EndIntervalOffsetY="0" CreateRefDef="1" Invisible="0" RefDef="Matching=0\nOnDelete=3\nOnUpdate=3\n" Comments="" FKRefDefIndex_Obj_id="-1" Splitted="0" IsLinkedObject="0" IDLinkedModel="-1" Obj_id_Linked="-1" OrderPos="15" /> </RELATIONS> <NOTES /> <IMAGES /> </METADATA>- <PLUGINDATA> <PLUGINDATARECORDS /> </PLUGINDATA>- <QUERYDATA> <QUERYRECORDS /> </QUERYDATA> <LINKEDMODELS /> </DBMODEL> Compartilhar este post Link para o post Compartilhar em outros sites
brshare 0 Denunciar post Postado Novembro 3, 2006 As campos das tabelas de endereço são iguais? Se forem, faça uma só tabela.é como te expliquei to usando uma tabela endereços so que ai como irei relacionar clientes e funcionarios com esta tabela ?? Compartilhar este post Link para o post Compartilhar em outros sites
brshare 0 Denunciar post Postado Novembro 3, 2006 Hummm. Saquei.Os ids de clientes e funcionários são auto_increment, certo?Faz assim então na chave primária:id_endereco | id_dono | tipo_dono create table clientes{ id_cli integer not null auto_incremment}create table funcionarios{id_fun integer not null auto_incremment}create table enderecos{ id_end integer not null auto_incremment}e agora para onde as chaves migram ???? Compartilhar este post Link para o post Compartilhar em outros sites
Suissa 1 Denunciar post Postado Novembro 7, 2006 pelo q eu saiba clientes e funcionarios são duas coisas bem diferentes logo o end de um func tb eh diferente do end do clienteentaum se você criar as 2 tabelas você estara sim dentro das formas normaismas se quiser ser mais pratico cria uma tabela de endereços como PK somente o ID dela ae coloca um campo tipo (= func ou cli) e um campo cod q vai receber o id ou do func ou do cliente =D Compartilhar este post Link para o post Compartilhar em outros sites
[VAZA] 0 Denunciar post Postado Março 22, 2007 Cara..quanto a isso, tem uma materia falando sobre o DBDesigner e isso que você quer na SQL MAGAZINE...edição 35...eu to usando o DBdesigner e consegui tirar bastante duvidas através da materia dessa revista...você pode criar uma tabela chamada "enderecos" e para na tabela clientes e fornecedores, você chama um relacionamento generalizado, clicando na ferramenta New Generalization..no DBDdesigner..dai clica na tabela "enderecos" e depois na tabela clientes....dai mais uma vez clica na ferramenta New Generalization e depois na tabela "enderecos" e por fim na tabela "funcionario"flw aewt+ Compartilhar este post Link para o post Compartilhar em outros sites