2 Jul 2024

MySQL syntax coding guidelines

MySQL syntax coding guidelines help ensure that your SQL code is readable, maintainable, and efficient. Here are some key guidelines to follow: 


1. General Formatting

  • Consistent Capitalization: Use uppercase for SQL keywords (e.g., SELECT, INSERT) and lowercase for column and table names (e.g., table_name, column_name).
  • Indentation: Use indentation to align SQL statements and enhance readability, especially in complex queries.
  • Line Breaks: Place each clause (e.g., SELECT, FROM, WHERE, JOIN, ORDER BY) on a new line.

2. Naming Conventions

  • Tables and Columns: Use descriptive names for tables and columns. Avoid using reserved keywords and keep names concise but meaningful.
  • Prefixes and Suffixes: Use prefixes (e.g., tbl_ for tables) and suffixes (e.g., _id for primary keys) consistently if they add clarity.

3. SELECT Statements

  • Column Selection: List column names explicitly instead of using SELECT *.
  • Aliases: Use meaningful aliases for tables and columns to make the query easier to understand.

4. JOINs

  • Explicit JOINs: Prefer explicit JOIN syntax over implicit joins (comma-separated lists in the FROM clause).
  • Join Conditions: Always use ON clauses for join conditions to clarify the relationship between tables.

5. WHERE Clauses

  • Conditions: Use appropriate operators and functions to filter data efficiently. Place conditions that reduce the result set size early in the clause.
  • Formatting: Align conditions vertically to improve readability when multiple conditions are used.

6. Subqueries

  • Readability: Format subqueries with proper indentation. If a subquery is complex, consider breaking it into a Common Table Expression (CTE).

7. Comments

  • Inline Comments: Use comments to explain complex logic or important details within the code. Use -- for single-line comments and /* ... */ for multi-line comments.
  • Block Comments: At the beginning of scripts or complex sections, provide a summary of the purpose and functionality.

8. Transactions

  • Atomicity: Group related operations within transactions using START TRANSACTION, COMMIT, and ROLLBACK to ensure atomicity.
  • Error Handling: Include error handling to manage exceptions and ensure data integrity.

9. Indexes

  • Index Usage: Use indexes to optimize query performance but avoid over-indexing, which can slow down insert and update operations.
  • Index Naming: Use a consistent naming convention for indexes, such as idx_table_column.

10. Performance

  • Query Optimization: Analyze and optimize queries using EXPLAIN to understand their execution plan.
  • Batch Operations: For bulk inserts or updates, use batch operations to reduce the number of database hits.

Example

-- Select users with their respective orders SELECT u.user_id, u.username, o.order_id, o.order_date FROM users u JOIN orders o ON u.user_id = o.user_id WHERE u.status = 'active' AND o.order_date >= '2024-01-01' ORDER BY o.order_date DESC;

By following these guidelines, you can write SQL code that is clean, efficient, and easy to maintain.

28 Jun 2024

How to insert new Products data and custom Price Books via Data Loader

Importing product names and prices into a custom price book in Salesforce involves a few steps: preparing your data, adding products to the standard price book, and then associating these products with the custom price book along with the specific pricing. Here’s a detailed guide on how to achieve this:


Create and activate a Product Price Book

Step 1 - Set up Price Books

You can create Price Books in Salesforce directly for a small finite set of Price Books. For creating multiple Price Books, you can use the Data Loader and import into the 'PriceBook2' object. Review Insert or update Price Books with Data Loader.

  1. In SFDC, click the Products tab.
  2. In the bottom right-hand corner, click Manage Price Books.
  3. Add as many Price Books as necessary. 
  4. The Standard Price Book MUST be active.

Import Products via the Data Loader

Step 2 - Prepare Product file

  1. Make sure all Products have a Product Name. This is a required field when loading Products into the 'Products2' object.
  2. If you use Record Types, you will need the 'RecordTypeID' for the insert file. Export the 'Record Type' field via the Data Loader (you will need to check 'Show all Salesforce Objects'). This export will provide the 18-digit ID, which is needed for the insert.
  3. Make sure your column headers in the file exactly match the fields in Salesforce.
  4. Open Data Loader and insert to 'Products2' object.
  5. Save success and error files in a folder, you will use them in the Step 3b.

Prepare the product data like this:
  • Name
  • Product A
  • Product B




Associate Products with Standard Price Book and Custom Price Books via the Data Loader

Step 3 - Export 'Price Book 2' object

Please use the 'PriceBook2 ID' (from Step 2a) and other fields to prepare a file for the next step.

  1. Open the Data Loader.
  2. Export the 'PriceBook2' object.
  3. You need 'PriceBook2 ID' for insert file.
  4. Save file in an easy to access location.
  5. This will be used to create your final insert file for Step 3c and 3e.

 
Step 4 - Prepare file for Standard Price Book

Note: Always first associate the Products with the Standard Price Book irrespective whether the Products are using Standard Price or not.

  1. Data Columns:
  1. Product2ID: Use the 'ID' from the 'Product2' success file from Step 2.
  2. PriceBook2ID: Get the Standard Price Book ID from file created in Step 3a.
  3. CurrencyIsoCode: (only for multi-currency orgs) Use SFDC currency symbol.
  4. Unit Price: this is the List Price/Standard Price field for the Product.
  5. UseStandardPrice: Do not map this field for Standard Price Book.
  6. IsActive: TRUE (must be TRUE to insert - this can be changed to FALSE after Step 5 is complete)
 
  1. Open the Data Loader click Insert, then under the list of Salesforce object choose Price Book Entry (PricebookEntry).
  2. Map the fields accordingly and do the import.
  3. Save success and error files in a folder.

Prepare the CSV with Product2Id, Pricebook2Id, UnitPrice, IsActive

Product2Id,Pricebook2Id,UnitPrice,IsActive
01t1N00000xxxxxxxx,01s1N00000Standard,100,true
01t1N00000yyyyyyyy,01s1N00000Standard,150,true



Step 4 - Prepare the file for Custom Price Books
 
  1. Use the file from last step and modify it to have the custom Price Book ID.
  2. The field UseStandardPrice plays an important role in inserting Price Books for custom Price Books: This should be TRUE (or 1) or FALSE (or 0) and indicates whether to use the price from Standard Price Book or not. See our SOAP API Developer Guide for PricebookEntry.
  1. FALSE (this choice means you will use the Unit Price from the custom Price Book and NOT the Unit Price from the Standard Price Book).
  2. TRUE (this option only works if this Product has been added to the Standard Price Book. This choice will use the Unit Price from the Standard Price Book. Note: Please provide the same unit price value as that of Standard Price book in this scenario).
  1. Follow the steps as provided in the Step 3b for Customer Price Book ID.

Prepare the CSV with Product2Id, Pricebook2Id, UnitPrice, IsActive, UseStandardPrice.

Product2Id,Pricebook2Id,UnitPrice,IsActive,UseStandardPrice

01t1N00000xxxxxxxx,01s1N00000Custom,90,true,false

01t1N00000yyyyyyyy,01s1N00000Custom,140,true,false




You can check Manage Price Books for you to track the prices of products and services that your company offers to customers.

21 Nov 2023

How to install VueJS, Vuex in Laravel 8 with its dependencies library

 In this post, you will be learning how to install or Set up Vue JS, Vuex, Saas, Vue-loader and its dependencies libraries in Laravel 8.

Step 1: Install Laravel 8 as follows:

$ composer create-project --prefer-dist laravel/laravel laravelvue "8.0.*"

Step 2: Install Vue with Laravel UI Package as follows:

$ composer require laravel/ui
$ php artisan ui vue --auth

Step 3: After ui vue auth successfully installed. Let's run the command for setup node modules as follows:

$ npm install

Step 4: Let's Install Vue as follows:

$ npm install vue

Step 5: Now, Let's install all required VUE tools and libraries by a single command:

$ npm install vue-template-compiler vue-loader vue-router vuex axios vue-axios  --save-dev --legacy-peer-deps

Step 6: Run the command to build the development package by following cmd:

$ npm run dev

Step 7: You are done. Lets run the application by:

$ php artisan serve
$ npm run watch

19 Oct 2023

Email Sentences and Phrases in different situations

20 Sentences and Phrases for Beginning an Email 

  1. Thank you for your message/email/phone call. 
  2. I hope you are doing well. 
  3. I hope you had a great weekend. 
  4. I hope this finds you well. 
  5. Just checking in. 
  6. Thanks again for your help. 
  7. It was great talking to you. 
  8. It was great meeting you. 
  9. Thanks for the additional info. 
  10. Just wanted to send you a quick note to... 
  11. How is everything? 
  12. Thanks for the quick response. 
  13. Thanks for your help with. 
  14. I have a quick question. 
  15. I have a quick request. 
  16. Thanks for the update. 
  17. Just checking in to make sure that. 
  18. I wanted to reach out to you because. 
  19. I am looking forward to. 
  20. It is great to hear from you 

20 phrases for closing an email


Expressions for thanking 

  1. Thank you for your help. / time / assistance / support 
  2. I really appreciate the help. / time / assistance / support you’ve given me 
  3. Thank you once more for your help in this matter. 


Expressions with a future focus 

  1. I look forward to hearing from you soon / meeting you next Tuesday. 
  2. I look forward to seeing you soon._ 
  3. I’m looking forward to your reply._ 
  4. We hope that we may continue to rely on your valued custom. 
  5. We look forward to a successful working relationship in the future. 
  6. Please advise as necessary. 
  7. I would appreciate your immediate attention to this matter. 


Expressions for showing them You want to help 

  1. If I can be of assistance, please do not hesitate to contact me. 
  2. If you require any further information, feel free to contact me. 
  3. If you require any further information, let me know. 
  4. Please feel free to contact me if you need any further information. 
  5. Please let me know if you have any questions. 
  6. I hope the above is useful to you. 
  7. Should you need any further information, please do not hesitate to contact me. 
  8. Please contact me if there are any problems. 
  9. Let me know if you need anything else 
  10. Drop me a line if I can do anything else for you.

11 Oct 2023

How to protect your website against DDoS attacks

Intro

Experts believe that the total number of DDoS attacks will double from the 7.9 million seen in 2018 to over 15 million by 2023. One of the reasons for this significant increase is that DDoS attacks are quite easy to pull off, making them very appealing to cyber criminals around the world.


Research states that small businesses can suffer damages of up to $120,000 per DDoS attack, while enterprise-level attacks can cost as much as $2 million.


So it really doesn’t matter whether you’re a small business or a huge multinational conglomerate, your online services, including email, websites, and anything that faces the internet, can be slowed down or completely blocked by a DDoS attack.


In this article, we list the most common types and offer resources to protect against DDoS attacks.



DDoS Attacks in a Nutshell


Distributed Denial-of-Service or DDoS attacks are malicious attempts to block businesses from its traffic. During a DDoS attack, the target server is flooded with bad traffic generated by exploited systems on the internet.


When your site falls victim to a DDoS attack, your website becomes unavailable for a while, or a very long time, depending on the intensity of the attack. Protecting your website against DDoS attacks means implementing a series of solutions to deal with the fake traffic sent by hackers to overwhelm your server resources.


Website owners shouldn’t need to wait until their site is under attack before they act. It is recommended to adopt a proactive approach towards DDoS attacks, and here are some non-technical, effective solutions to protect your website against this malicious traffic.


Effective tactics to mitigate DDoS attacks

Here’s what you could do to protect your site or web apps against various types of DDoS attacks and help to keep your website online all the time.

1. Increase bandwidth

One of the most basic steps you can take to protect against DDoS attacks is to make your hosting infrastructure “DDoS resistant”. In essence this means that you prepare enough bandwidth to handle traffic spikes that may be caused by cyber attacks.

Please be reminded however that purchasing more bandwidth itself does not satisfy as a complete solution to mitigate DDoS attacks. When you increase bandwidth, it does raise the bar which attackers have to overcome before they can launch a successful DDoS attack, but you should always combine this with other mitigation tactics to completely safeguard your website.




2. Leverage a CDN Solution, or even better Multi CDN

CDN providers offer plenty of cybersecurity features and tools to protect your website from hackers. They also offer free SSL certificates. What’s more, when you add your website to these service providers, by default it provides DDoS protection to mitigate attacks on your server network and application.

The rationale behind this is that when you leverage a CDN network, all malicious requests targeting L3/L4 that aren’t accessing via port 80 and 443 will be filtered out automatically thanks to CDN’s port protocol.

Using a CDN can balance out website traffic so that your capped server would not be overwhelmed. Also, CDNs spread your traffic across servers in different locations, making it difficult for hackers to spot your original server to launch an attack.

In addition, with a Multi CDN solution you’ll be able to make use of a large network of PoPs from not one, but multiple CDN providers, allowing your website to sustain DDoS attacks via an even larger, multi-terabit-per-second globally distributed network.

3. Implement server-level DDoS protection

Some web hosts include server-level DDoS mitigation tools in their offering. As this feature is not always offered by web hosting companies, you should check with your web host. Some companies include it as a free service, while others offer it as a paid add-on. It all depends on the provider and hosting plan.



4. Fear the worst, plan for DDoS attacks ahead

Planning for a cyberattack in advance, enables you to respond quickly before they actually start harming your website.

A proper cyber security plan includes a list of co-workers who will deal with the attack. It also outlines the way the system will prioritize resources to keep most apps and services online, which could keep your business from crashing. Finally, you can also plan how to contact the Internet Service Provider that’s supporting the attack, since they may be able to help stop it entirely.

5. Remind yourself that you’re never ‘too small’ to be DDoS’ed

Many small business owners think that they’re scale isn’t large enough to fall victim to cyber attacks. However, as truth has it, cyber criminals target small businesses and startups more often than large enterprises. This is because bigger companies usually are more inclined to implement security solutions to deal with hacker’s attempts.

As mentioned earlier, small businesses can suffer damages of up to $120,000 per DDoS attack, so, your website is a possible victim to hackers and you should work on enhancing your website’s security.

6. Switch to a hybrid or cloud-based solution

When you switch to using hybrid or cloud-based services, chances are that you’ll have access to unlimited bandwidth. Many websites that are affected by DDoS are sites which run with limited resources. Moving to a cloud-based solution can help you be on the safe side.



7. Bullet-proof your network hardware configurations

You can prevent a DDoS attack by making a few simple hardware configuration changes.

For instance, you can configure your firewall or router to drop incoming ICMP packets or block DNS responses from outside your network (by blocking UDP port 53). This will help protect against certain DNS and ping-based volumetric attacks.