|
In the rare time when I have had to do this I live without the FK, it is not possible to have the FK to both child tables.
I suspect your 28 field count on the merged table is not valid, there should be some cross over (description in both tables). I would also have no compunction about merging the tables and having some nullable fields as Mika suggested.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Dilkonika,
This is a typical supertype-subtype situation. I would consider ITEM as a supertype and ARTCLE and SERVICE as subtypes.
Common attributes of ARTICLE and SERVICE should go to ITEM and there should be identifying relationship from ARTICLE and SERVICE to ITEM.
I dont know how to attach an ER Diagram hence pasting a DDL for the schema.
CREATE TABLE [ITEM]
(
[item_id] char(18) NOT NULL PRIMARY KEY,
[name] char(18) NULL
)
go
CREATE TABLE [SERVICE]
(
[item_id] char(18) NOT NULL PRIMARY KEY,
[nr] char(18) NULL ,
[value] char(18) NULL
)
go
CREATE TABLE [ARTICLE]
(
[item_id] char(18) NOT NULL PRIMARY KEY,
[category] char(18) NULL
)
go
CREATE TABLE [SELL_ITEM]
(
[id] char(18) NOT NULL PRIMARY KEY,
[quantity] char(18) NULL ,
[price] char(18) NULL ,
[value] char(18) NULL ,
[item_id] char(18) NULL
)
go
ALTER TABLE [SERVICE]
ADD CONSTRAINT [R_2] FOREIGN KEY ([item_id]) REFERENCES [ITEM]([item_id])
go
ALTER TABLE [SELL_ITEM]
ADD CONSTRAINT [R_3] FOREIGN KEY ([item_id]) REFERENCES [ITEM]([item_id])
go
ALTER TABLE [ARTICLE]
ADD CONSTRAINT [R_1] FOREIGN KEY ([item_id]) REFERENCES [ITEM]([item_id])
go
|
|
|
|
|
I have Some table in database (Access, SQLServer and Oracle) haven' t Primary Key.Client need to do a replication for this database.
I ask how do the update script for one table to add primary key as GUID automatic (it means when I add a record as before there is no need to edit source code)
I did this for SQLServer and it works but for Access and Oracle no idea how to do this
example :
create table [SAC_MEMBERSHIPS](
id_group nvarchar(40) FOREIGN KEY REFERENCES SAC_SUBJECTS(id_subject),
id_user nvarchar(40) FOREIGN KEY REFERENCES SAC_SUBJECTS(id_subject),
id_memberships UNIQUEIDENTIFIER NOT NULL DEFAULT NEWSEQUENTIALID() PRIMARY KEY
)/
ALTER TABLE [SAC_MEMBERSHIPS]
ADD [id_memberships] UNIQUEIDENTIFIER NOT NULL DEFAULT NEWSEQUENTIALID() PRIMARY KEY
ON [PRIMARY]
/
|
|
|
|
|
create table [table] (
id raw(32) default sys_guid(),
...,
constraint pk_id primary key (id)
);
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Thank you for that.
But what about Access database ?
|
|
|
|
|
I don't know him!
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
I talk about Microsoft Office access
|
|
|
|
|
Please do not use rude words here...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
|
The only mistake you did that you didn't realized the joke icon
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
For ms access the best approximation is
id_memberships AUTOINCREMENT PRIMARY KEY
Cheers
|
|
|
|
|
Thank you , But I need it to be in automatic GUID forme.
|
|
|
|
|
What are you going to do if the record is updated rather than added?
|
|
|
|
|
Also Access has a Guid datatype.
CREATE TABLE [SAC_MEMBERSHIPS]
(
[id_memberships] GUID NOT NULL PRIMARY KEY,
...
|
|
|
|
|
I use
id_memberships GUID PRIMARY KEY DEFAULT GenGUID() NOT NULL
But I can do in Update Request SQL
Have you an idea how do the Update ?
|
|
|
|
|
how do download a excel file from a website by using that website url(.csv) in c# code, in design section file shuld download on a button click and save in my system tell me the full procedure
|
|
|
|
|
This is not a question that can be answered in a few lines. You need to go and research some of the libraries that can be used to download files.
|
|
|
|
|
I JUST WANT PROCEDURE NOT A CODE OR SOMETHIN ...
|
|
|
|
|
The procedure is:
- Collect requirements
- Research tools and libraries
- Write code
- Test, diagnose problems, and correct errors.
- Repeat above until working
|
|
|
|
|
Let me add another important step to Richard's answer:
divide and conquer
Split the problem into smaller pieces until you can solve each of those smaller pieces. If you can't solve it yet, try to split it further.
In case you are later stuck with a specific problem, come back to this site and ask a specific question.
|
|
|
|
|
Hi,
I would like to ask how can I delete duplicate records in MySQL from my fingerprint table.
I need to delete any record if found the same created_date AND created_time AND employee_number
Thanks,
Jassim
Technology News @ www.JassimRahma.com
|
|
|
|
|
Don't use MySQL but in SQl server you would do this:
WITH CTE_fingerprint
AS (
SELECT
employee_number
,created_date
,created_time
,ROW_NUMBER() OVER (
PARTITION BY
employee_number
,created_date
,created_time
ORDER BY
employee_number
,created_date
,created_time
) AS RowNumber
FROM [fingerprint]
)
DELETE
FROM CTE_fingerprint
WHERE RowNumber > 1;
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
Not sure with self-joins in MySQL.
This query should show you all the duplicates (assuming ID is the identifier in the table):
SELECT *
FROM fingerprint t1 inner join fingerprint t2 on
t1.created_date=t2.created_date and t1.created_time = t2.created_time and t1.employee_number=t2.employee_number
Where t1.ID<t2.ID
Next, change SELECT * to SELECT t1.ID to get the ID values of the duplicates only, then do a delete query with a subquery:
DELETE
FROM fingerprint
WHERE fingerprint.ID IN
(
SELECT t1.ID
FROM ... (see query above)
)
|
|
|
|
|
Hi,
I'm facing a real challenge in a report I've built with MDX in SSRS.
I have "Keywords" (Dim) column, and "Cost" (Measure) column.
There are a lot of the same keywords (each from different Campaign, which name I preset in the KW tool tip).
I need to make sure that all KWs from the same kind will display one after the other.
The problem is, I need to make sure it's stays in that order even when sorting (interactively) the "Cost" column. basically, the sorting will start again after each group of keywords. And I must display each one of the KWs, not grouping them to 1.
Is it possible? what is the best solution?
Thanks!
|
|
|
|
|
Hi,
There is column for mobile number in my table whose data type is string.
I have to replace six character from middle with star(*) from the string of 10 characters.
For example
The Contact number is 9334459875
I have to display it as follows
93******75 first two characters and last two characters only.
|
|
|
|