Monday, October 18, 2010

File attachment using Adf faces, EJB3 and Oracle XE database Part I


I want to associate files with employees (PERSON). I will have employees(PERSON) with their associated files which will hold the more information for that employees (PERSON) like (employee’s picture, list of his dependant, his Resume etc)

My ERD will have PERSON and ATTACHMENT tables, and a join table between PERSON and ATTACHMENT that is PERSON_ATTACHMENT.

The relation between PERSON AND ATTACHMENT is ONE TO MANY, A single employee (PERSON) can have many attachments.
Step # 1 Creating tables in Oracle database XE
Let’s first create the Tables in Oracle XE Database.
Open your Oracle Database XE by clicking on “Startup” select “Oracle Database 10g Express Edition” and then click on “Go to Database Home page”
Login to Oracle Database XE.
Creating PERSON  Table

PERSON table

PERSON table also create sequence for PERSON table

PERSON table
Create Attachment table with three columns "ATTACHMENT_ID", "FILE_CONTENT" & "FILE_NAME"

ATTACHMENT table, also create sequence for attachment table

Create join table between PERSON and ATTACHEMTN as "PERSON_ATTACHMENT".


PERSON_ATTACHMENT table, make composite primary key

Create Foreign keys

Create Foreign keys

 While creating tables we also added sequences and it causes to generate triggers as well, so in our case we need to delete these triggers, 1. In Object browser select "Triggers" in dropdown, it will show you all the triggers, in our case there will be only two triggers with the name "BI_ATTACHMENT" and "BI_PERSON"
Following are the steps to remove the triggers.

Remove these triggers as follows



To be continue-->
Comming up next
Step II Creating Entities from Database tables, Creating Session beans

No comments:

Post a Comment