Flash Components      Flash Menu      Flash Gallery      Flash Slideshow      FLV Player      Flash Form      MP3 Player      PhotoFlow      Flash CMS      3D Wall      Flash Scroller

Flash / AS

Silverlight

WPF

ASP.net / PHP

Photoshop

Forums

Blog

About

 


FlashComponents
  Galleries
  Slideshows
  Menus
  Design & Effects
  Audio & Video
  User Interface
  Templates

 

 

Relational Database Design - Page 7
       by Brian Haveri aka bwh2 | 2 October 2006
 

The Clients Table
At this point, you might have an idea what's coming next: tbl_clients. Appropriately, tbl_clients will have client_id as the primary key set to auto increment.

/***** CREATE tbl_clients *****/
CREATE TABLE `tbl_clients` (
`client_id` INT NOT NULL AUTO_INCREMENT,
`client_name` VARCHAR(20) NOT NULL,
PRIMARY KEY (`client_id`)
)
TYPE = myisam;
/***** End CREATE *****/

/***** INSERT sample data into tbl_clients *****/
INSERT INTO `tbl_clients` (
`client_id`, `client_name`
)
VALUES (
'',
'Johnson Photography'
);
INSERT INTO `tbl_clients` (
`client_id`, `client_name`
)
VALUES (
'',
'Super Duper Company'
);
INSERT INTO `tbl_clients` (
`client_id`, `client_name`
)
VALUES (
'',
'Smith News Service'
);
/***** End INSERT *****/
 

As with categories and technologies, we will use a mapping table: tbl_works_clients to map which works were for which clients. Even though one work may only belong to one client, a good relational design will still show the relationship in a separate table instead of placing it in tbl_works.


tbl_works_clients Database ERD

 

/***** CREATE tbl_works_clients *****/
CREATE TABLE `tbl_works_clients` (
`work_id` INT NOT NULL,
`client_id` INT NOT NULL
)
TYPE = myisam;
/***** End CREATE *****/

/***** INSERT sample data into tbl_works_clients *****/
INSERT INTO `tbl_works_clients` (
`work_id`,
`client_id`
)
VALUES (
'1',
'1'
);
INSERT INTO `tbl_works_clients` (
`work_id`,
`client_id`
)
VALUES (
'2',
'3'
);
INSERT INTO `tbl_works_clients` (
`work_id`,
`client_id`
)
VALUES (
'3',
'2'
);
INSERT INTO `tbl_works_clients` (
`work_id`,
`client_id`
)
VALUES (
'4',
'2'
);
/***** End INSERT *****/
 

Then we can query across our client tables just as we did with categories and technologies. For instance:

/*
Gets the client names associated with work_id #1
Should return 1 row with the client_name = 'Johnson Photography'
*/
SELECT c.client_name
FROM tbl_works a,
tbl_works_clients b,
tbl_clients c
WHERE a.work_id = 1
AND a.work_id = b.work_id
AND b.client_id = c.client_id
 

Onwards to the next page!

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8


kirupa.com's fast and reliable hosting provided by Media Temple. flash components
The Text Animation Component for Flash CS3
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.
Check out our high quality vector-based design packs! Flash Effect Components

Flash Templates
CSS Templates
Dreamweaver Templates

flash menus, buttons and components
Digicrafts Components The best flash components ever!
Entheos Flash Website Templates Buy and sell FLAs at Ultrashock!
Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com Purchase & Download Flash Components
flash components Learn how to advertise on kirupa.com