Tuesday, 22 January 2013

MySQL Cascade Example

MySQL Cascade Example

Q1: When parent record deleted, child must be deleted automatically. But if child record deleted, parent should not effected.

Q2: I want to understand the mysql constraint cascade.

Q3. How a child record deleted automatically when parent deleted.

Above all Questions have only one answer that is below with fine example.

Create a table products
CREATE TABLE products (
    id int unsigned not null primary key AUTO_INCREMENT,
    name varchar(255) default null 
); 

Create a table reviews, as each product have one or more reviews

CREATE TABLE reviews (
    id int unsigned not null primary key AUTO_INCREMENT,
    review_by int(11) unsigned not null,
    product_id int(11) unsigned not null,
    points int(11),
    FOREIGN KEY (product_id) REFERENCES products (id) ON DELETE CASCADE  ON UPDATE CASCADE
  )


Now, if you delete a product, then its review (product's review) will be automatically deleted. but if you delete the child parent record will be untouched/uneffected.

Friday, 18 January 2013

MX Record Explanation


What is MX Record?
Full Form of MX Record is "Mail Exchanger record".
It is type of resource record in DNS(Domain Name Server) that is responsible for email messages on the behalf of receipts domain. maile exchanger records of a domain  specifies how email should be routed with the SMTP.


Why we use MX Record?
Mail exchanger(MX) entries are used when want to send SMTP(Simple Mail Transfer Protocol) mail to a remote system.
MX records are the responsibility for the domain name server.

How to Check MX entry for a domain?
http://mxtoolbox.com/SuperTool.aspx


What's the format of an MX record? 
An MX record includes the following fields:
Name: The name of your domain.          
Class: This is always set to IN, which stands for Internet.
Type: For MX records, this is always set to MX.
TTL: "Time to Live." How long it will take to update the record. This is measured in seconds. A TTL of 3600 seconds means records will take an hour to update. A TTL of 86400 means records will take a day to update. A higher TTL value means less traffic load for the DNS server, but it also means that changing the MX records will take longer.
Preference or Priority: The order of preference for mail delivery. Sending servers should try the lowest preference number first, then the next lowest, and so on.
Data: The host name of the mail server that handles mail for that domain.
For instance, if your domain is jumboinc.com, your MX records might look like this:
jumboinc.com. IN MX 86400 1 jumboinc.com.s7a1.psmtp.com.


How long do MX record updates take?
MX record updates are not immediate. After you've updated your MX records, it will take a while for every sender to use the new MX records. Your original TTL setting determines how long (in seconds) this will take. Changing the TTL setting won't speed this up.

What happens when I update my MX records?
Once you update your MX records, mail will start flowing through the message security service. After your old previous TTL (in seconds) has expired, all your mail flows through the message security service. When your mail flows through the service, mail is bounced from IP addresses known to be a major source of spam attacks or viruses. Also, if you have Non-Account Virus Blocking, mail to users will be filtered for viruses as well. You'll get complete mail filtering after you've added your users.