Data synchronization on multiple locations:
Application is deployed on different locations, I want to update master database at the end of day such that new sales orders of the day from all locations
should be inserted into master database.
At the time of insertion of a new sales order in the local database at a particular location,
application first ensure that this customer is new customer who is not in the local as well as master database.
If customer data is already present in the master database , then local database must be populated with essential details of a customer available in the master
daabase.
Customer:
CUST_ID sequence (PK)
Name varchar2
DOB DateTime
SSN DateTime
Customer_Detail:
CUST_ID (FK) Refrences Customer,
PhoneNumber
email
Customer_Order:
Order_ID
CUST_ID
Order_Date
Order_Detail:
Order_ID
Product_Id
Quantity
At the end of day I want to update the master database, with all the details of new data that is inserted in the databases on different locations.
The approach which i want to follow is:
searchMasterDatatabse(ssn)
{
//select name, dob,ssn from customer where ssn=:ssn
if(recordFound)
set recordExistInMasterDatabase=true;
}
if (recordExistInMasterDatabase)
{
insert into location.Cutomer(name,dob,ssn) values(master.name,master,dob,master.ssn)
}
else
{
insert into location.Cutomer(name,dob,ssn) values('John','19-MAR-2012','1111-222222-8989888'}
}
Now at the end of day i want to update the master database with the new customers that are registered on different locations.
Please suggest me the articles, techniques, tutorial so that i can achive the above functionality. I want to start my work after deciding a particular technique.
Is there any tool to do this?
What about oracle data integrator?
Should I implement web service to communicate with the master database?
I want to implement this using pure java + oracle sql + jsf for web.
I have eclipse, oracle 11g.
Related
I'm looking for a right solution for database structure regarding user permissions.
Tables:
users
companies (relevant columns: id)
projects (relevant columns: id,company_id)
jobs (relevant columns: id, company_id,project_id)
Scenarios I want to accomplish is to have specific user and/or users assigned to:
all the projects within company ("Cindy is assigned to all projects and all jobs within company")
select projects within company ("Cindy is assigned to three out of five projects and is assigned to all jobs within those three projects")
selected job(s) within project(s) ("Cindy is assigned to five jobs out of ten within one project and two jobs within the other project")
I think about separate permissions table where I just insert permissions to relevant jobs and to use the relevant columns from jobs table to cascade permissions upwards. In other words - if a user has permission for a specific job then it also has permission for parent project and parent company.
SQL Fiddle: http://sqlfiddle.com/#!9/74a4d3/2
Here is a proposed table structure for permissions:
USER_ID OBJ_TYPE OBJ_ID PERMISSION
JDOE COMPANY 1 1-READONLY
JDOE COMPANY 2 2-READWRITE
JDOE PROJECT 1 2-READWRITE
Then code to check user access could look something like:
SELECT MAX(permission) FROM permissions
WHERE user_id = :USERID
AND ( (obj_type = 'JOB' and obj_id = :JOBID)
OR (obj_type = 'PROJECT' and obj_id = :PROJECTID)
OR (obj_type = 'COMPANY' and obj_id = :COMPANYID))
I have a database has been running on a server. I also have a database running for about a month on a new server which has data based on the old server. Since these both have been running this past month, the data on them are not equal.
We want to move selective data from two tables in the old database to the new one. This is the select I want to move, one month of data:
select * from table1 left join table2 on table1.keyID = table2.keyID
where table2.updated between '2013-08-01' and '2013-08-31';
From my understanding I would probably need to dump each table on its own. However when inserting this data into the new database, I would need to give these entries new keyID (this is autogenerated). How can I do this while keeping the connection between these two tables?
Take a dump of table1 & table2 from the old server and restore it in the new server under the database name oldDB
I Assume your database name in new server is newdb
Insert into newdb.table1 (Field1,Field2,field3)
select Field1,Field2,field3
from olddb.table1
left join olddb.table2
on (olddb.table1.keyID = olddb.table2.keyID)
Where olddb.table2.updated between '2013-08-01' and '2013-08-31';
Please note that you have to specify all the fields in select statement except your KeyID field. KeyID number will be autogenerated by the database
I am assuming that the KeyID Field is Auto Increment field other wise this solution will not work
I have the following requirements:
Table Client has two columns ClientID(Int) and Email ID(Varchar 100). ClientID is an identity column with Auto increment value of 1.
Table Indicator has two columns ClientID(Int) and Paid(Char 1)
Both the table are joined with the Key clientID.
I am using MS SQL 2008 database. Can you pleases let me know how it is possible to update Indicator table automatically with clientID as soon as new record is created in Client.
Thanks for the assistance.
You can do it by using trigger or you can denormalize your data structure (if you have only Paid in Indicator, I think the Paid is simple property of Client) and move it to Client.
You can use trigger like this:
CREATE TRIGGER dbo.TrigerName
ON Client AFTER INSERT
AS
BEGIN
UPDATE I
SET Paid = <your value>
FROM Indicator I
JOIN inserted ins
ON I.ClientID = ins.ClientId
END
I'm trying to implement a feature whereby, apart from all the reports that I have in my system, I will allow the end user to create simple reports. (not overly complex reports that involves slicing and dicing across multiple tables with lots of logic)
The user will be able to:
1) Select a base table from a list of allowable tables (e.g., Customers)
2) Select multiple sub tables (e.g., Address table, with AddressId as the field to link Customers to Address)
3) Select the fields from the tables
4) Have basic sorting
Here's the database schema I have current, and I'm quite certain it's far from perfect, so I'm wondering what else I can improve on
AllowableTables table
This table will contain the list of tables that the user can create their custom reports against.
Id Table
----------------------------------
1 Customers
2 Address
3 Orders
4 Products
ReportTemplates table
Id Name MainTable
------------------------------------------------------------------
1 Customer Report #2 Customers
2 Customer Report #3 Customers
ReportTemplateSettings table
Id TemplateId TableName FieldName ColumnHeader ColumnWidth Sequence
-------------------------------------------------------------------------------
1 1 Customer Id Customer S/N 100 1
2 1 Customer Name Full Name 100 2
3 1 Address Address1 Address 1 100 3
I know this isn't complete, but this is what I've come up with so far. Does anyone have any links to a reference design, or have any inputs as to how I can improve this?
This needs a lot of work even though it’s relatively simple task. Here are several other columns you might want to include as well as some other details to take care of.
Store table name along with schema name or store schema name in additional column, add column for sorting and sort order
Create additional table to store child tables that will be used in the report (report id, schema name, table name, column in child table used to join tables, column in parent table used to join tables, join operator (may not be needed if it always =)
Create additional table that will store column names (report id, schema name, table name, column name, display as)
There are probably several more things that will come up after you complete this but hopefully this will get you in the right direction.
I had an old database with a single table containing customer orders and customer details. I went on to create a new database model using seperate tables for customers and details. I managed to migrate the customer details to the new database, but was unable to migrate the the cusomer orders. We thought that this would be ok, and that we would just build the order record from now on ignoring all previous orders in the old database. This was a while ago, and I cannot remember the exact reason why I was unable to import the customer orders. However, now we have discovered that we will need the old orders in the new database. Is there an easy way to do this using Microsoft Access?
This is the reason why:
Split a table in access into two linked tables
Depending on how complex your schema is, a simple approach would be schema-mapping by a INSERT INTO SELECT query.
For example if your old database had a table:
Orders
------
OrdID
CustID
ProductName
Price
oDay
oMonth
oYear
And your new database had fields with different names, extra fields, etc:
OrderDetails
------
Order_ID
Customer_ID
Product
Price
DeliveryAddress
OrderDate
All you would need to do was to create an insert query to append the old records to the new table. In defining the query, you can specify the source and destination field names, and you can even perform functions / expressions on the data. You can even query on the other table directly, without linking or importing it into your new database:
INSERT INTO OrderDetails (Order_ID,Customer_ID,Product,Price,OrderDate)
SELECT OrdID,CustID,ProductName,Price,DateSerial(oYear,oMonth,oDay) AS oDate
FROM Orders IN 'C:\oldDatabasePath.mdb';
If you have to do additional transformations to the data, such as run expressions on column values, I would recommend testing out the SELECT part of the query before adding the INSERT line.