Re: a problem about database modeling
Date: 20 Jul 2006 02:07:43 -0700
Message-ID: <1153386463.200212.262370_at_b28g2000cwb.googlegroups.com>
Bob Badour wrote:
> Marshall wrote: > > dxuranus wrote: > > > >>i have a entity 'device' and every 'device' has there own 'type' and > >>every 'type' has there specific attributes. > >> first i let the table 'device' keep all common attributs of device > >>,but i find i can't keep the 'device's type attributes at least i found > >>if i do that.it got be urgly and strangly. > >>so what can i do about this thanks for any help. > > > > Can you be more specific about the problem you are having? > > I don't know how to help with urgliness and strangliness. > > Hit it with an urgly stick and if that doesn't kill it strangly it with > a shoelace?
ok
i list my sql code here
table device:
CREATE TABLE `equ` (
`equ_id` varchar(32) NOT NULL default '',
`type_id` varchar(32) default NULL,
`equ_code` varchar(32) default NULL,
`equ_stat` varchar(32) default NULL, //device state
`equName` varchar(32) default NULL,
PRIMARY KEY (`equ_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8
table device attributes:
CREATE TABLE `equpro` (
`equ_id` varchar(32) NOT NULL default '',
`tp_id` varchar(32) NOT NULL default '', //device type attribute
id
`value` varchar(32) default NULL, //the value of
device type attribute
PRIMARY KEY (`equ_id`,`tp_id`),
KEY `equpro_FK` (`equ_id`),
KEY `equpro2_FK` (`tp_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
table device type:
CREATE TABLE `type` (
`type_id` varchar(32) NOT NULL default '',
`type_name` varchar(32) default NULL,
`type_father` varchar(32) default NULL,//the type's father(also a
type)
id
PRIMARY KEY (`type_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8
table device type attributes
CREATE TABLE `typepro` (
`tp_id` varchar(32) NOT NULL default '',
`type_id` varchar(32) default NULL,
`tp_name` varchar(32) default NULL,
`tp_code` varchar(32) default NULL,
`tp_note` varchar(32) default NULL,
`tp_others` varchar(32) default NULL,
`tp_null` tinyint(1) default NULL,
PRIMARY KEY (`tp_id`),
) ENGINE=MyISAM DEFAULT CHARSET=utf8
thanks for any help! Received on Thu Jul 20 2006 - 11:07:43 CEST