smit127 said:
I want to implement library for loanable items. A rental item table exists
which contains the bulk of the attributes but there are subtypes of this
being DVD, video and computer game which each contain specialized
information. When I add a DVD for example I want to add all the attributes
inherited from item plus the specialized attributes in DVD e.g. director, DVD
release.
Do you mean something like this:
CREATE TABLE RentalItems (
rental_item_code VARCHAR(9) NOT NULL,
CHECK (LEN(rental_item_code) = 9),
rental_item_type VARCHAR(35) NOT NULL,
CHECK (rental_item_type IN ('DVD', 'Video', 'Computer game')),
PRIMARY KEY (rental_item_type, rental_item_code),
<<generic attribute columns here>>
)
;
CREATE TABLE DVDs (
rental_item_code VARCHAR(9) NOT NULL,
rental_item_type VARCHAR(35) NOT NULL,
CHECK (rental_item_type = 'DVD'),
PRIMARY KEY (rental_item_type, rental_item_code),
FOREIGN KEY (rental_item_code, rental_item_type)
REFERENCES RentalItems (rental_item_type, rental_item_code)
ON UPDATE CASCADE ACTION ON DELETE CASCADE,
<<DVD-specific attribute columns here>>
)
;
And a similar table for each of Video, Computer game etc.
Of course, next you will want a Films table:
CREATE TABLE Films (
rental_item_code VARCHAR(9) NOT NULL,
rental_item_type VARCHAR(35) NOT NULL,
CHECK (rental_item_type IN ('DVD', 'Video')),
PRIMARY KEY (rental_item_type, rental_item_code),
FOREIGN KEY (rental_item_code, rental_item_type)
REFERENCES RentalItems (rental_item_type, rental_item_code)
ON UPDATE CASCADE ACTION ON DELETE CASCADE,
<<Film-specific attribute columns here>>
)
;
How can I do this in access?
To be able to use the above syntax, you need to either use Access2003
in 'ANSI-92' mode or use ADO in earlier versions e.g.
CurrentProject.Connection.Execute "<<SQL code here>>"
Jamie.
--