leehbi - Friday, February 17, 2017 9:19 AM
the first week of your database class? The definition of a primary key?It has to be made up of attributes in the table and not a physicalcount of things in the storage of the table. We also have a DATE datatype in SQL that you failed to use in the insertion statement. Hereis an attempt correct what you did
INSERT INTO Customers
VALUES
('078','1970-01-01', 'bob@bob.com', 'L1 3RT'),
('079','1981-01-02', 'bob@bob.com', 'L1 3RT'), – error
('034','1986-05-03', 'bert@aol.com', 'CH1 3ER'),
('078','1970-01-01', 'bob2@bob.com', 'L1 3RT1');
the two lines of the text of the insertion statement are wrong;they have a duplicate primary key, which is the email address. This should have been handled in an update of some kind to could change the birthdate. We really cannot fix the fact that you have a bad system with the improper performance.
>>I need to detect associations between customers - this is done bymatching customers where any 2 fields of [sic] the 4 (Mobile,birth_date, Email, PostCode) match. <<
do you understand the fundamental concept of RDBMS? Rows in the tablehave a key which makes them unique. You should have been scrubbing your data before you put it in the table to guarantee that you have actual real records. What you are doing is a way we used to do with Mag tapes and punchcards; throw a lot of bad data in a file sortedand then scan for payers a possible duplicates. We do not do that anymore.
>>The record [sic: rows are not records!] size is approx 2.5m. <<
please learn the difference between rows and records is one of your major problemsalso, what do you mean the size of a row is 2.5 m?
>>Everything I've tried to date is too slow, for instance self-joins on pairs of fields [sic]. <<
you do you understand the problem is that you are trying to clean up the mess you make after you make it? Do not let the bad data get in in thefirst place.
>>I've not tried cursors as think this will be a no no too. <<
oh yes! This like walking on to a vegan website and saying that you want to eat fried babies. :crying::crying:
Please post DDL and follow ANSI/ISO standards when asking for help.