<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sri Mahalakshmi</title>
    <description>The latest articles on DEV Community by Sri Mahalakshmi (@srimaha_17).</description>
    <link>https://dev.to/srimaha_17</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3682352%2F20dbd3e7-cc12-4878-9b4a-e36fcf2d29e9.jpg</url>
      <title>DEV Community: Sri Mahalakshmi</title>
      <link>https://dev.to/srimaha_17</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/srimaha_17"/>
    <language>en</language>
    <item>
      <title>Idempotency in a Digital Wallet System</title>
      <dc:creator>Sri Mahalakshmi</dc:creator>
      <pubDate>Sun, 29 Mar 2026 09:33:40 +0000</pubDate>
      <link>https://dev.to/srimaha_17/idempotency-in-a-digital-wallet-system-1mih</link>
      <guid>https://dev.to/srimaha_17/idempotency-in-a-digital-wallet-system-1mih</guid>
      <description>&lt;p&gt;In digital wallet systems like PhonePe or GPay, the same request can sometimes be sent multiple times due to network issues or retries. If the system processes the same request more than once, it can lead to incorrect balances. This is where idempotency becomes important.&lt;/p&gt;

&lt;p&gt;To understand this, I performed a simulation using the accounts table with two users, Alice and Bob. Initially, their balances were 600 and 700.&lt;/p&gt;

&lt;p&gt;First, I performed a transfer of 200 from Alice to Bob. After executing the queries, the balances became 400 for Alice and 900 for Bob.&lt;/p&gt;

&lt;p&gt;Then, I repeated the same transfer operation again, simulating a duplicate request. After running the same queries again, the balances changed to 200 for Alice and 1100 for Bob.&lt;/p&gt;

&lt;p&gt;This shows that the system processed the same request multiple times, leading to repeated deductions and credits. The system did not prevent duplicate execution.&lt;/p&gt;

&lt;p&gt;From this experiment, it is clear that without proper handling, repeated requests can cause inconsistent data. In real-world systems, techniques like unique transaction IDs or idempotency keys are used to ensure that the same request is processed only once.&lt;/p&gt;

&lt;p&gt;This helps maintain correct balances even if a request is sent multiple times.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu3lup1g3fib490tsup3m.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu3lup1g3fib490tsup3m.PNG" alt=" " width="641" height="339"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqerc0gytz6x5xu4md09j.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqerc0gytz6x5xu4md09j.PNG" alt=" " width="636" height="193"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>backend</category>
      <category>database</category>
      <category>systemdesign</category>
    </item>
    <item>
      <title>Managing Roles and Permissions in PostgreSQL</title>
      <dc:creator>Sri Mahalakshmi</dc:creator>
      <pubDate>Sun, 29 Mar 2026 09:22:40 +0000</pubDate>
      <link>https://dev.to/srimaha_17/managing-roles-and-permissions-in-postgresql-f6m</link>
      <guid>https://dev.to/srimaha_17/managing-roles-and-permissions-in-postgresql-f6m</guid>
      <description>&lt;p&gt;In a database system, controlling who can access and modify data is very important. In real-world applications like digital platforms, different users should have different levels of access based on their role. To understand this, I performed a series of tasks using the DVD Rental database in PostgreSQL.&lt;/p&gt;

&lt;p&gt;First, I created a role called report_user with login access and gave it permission to read only from the film table. This ensured that the user could view data but not modify it.&lt;/p&gt;

&lt;p&gt;Next, I tested access to the customer table using this role. As expected, PostgreSQL denied permission because no access had been granted. I then fixed this by giving SELECT permission on the customer table.&lt;/p&gt;

&lt;p&gt;After that, I restricted access further by allowing report_user to view only specific columns: customer_id, first_name, and last_name. This demonstrated column-level security, where users can see only the required data instead of the entire table.&lt;/p&gt;

&lt;p&gt;Then, I created another role called support_user. This role was given permission to read from the customer table and update only the email column. At the same time, delete access was not provided, ensuring that important data could not be removed.&lt;/p&gt;

&lt;p&gt;In the next step, I removed the previously given SELECT permission on the film table from report_user, showing how permissions can be revoked when no longer needed.&lt;/p&gt;

&lt;p&gt;I also created a group role called readonly_group and granted it SELECT access on all tables. Then, I created two users, analyst1 and analyst2, and added them to this group. This allowed both users to inherit read-only access without assigning permissions individually.&lt;/p&gt;

&lt;p&gt;Through this exercise, I understood how PostgreSQL manages roles and permissions effectively. It allows fine-grained control over data access, ensuring security and proper usage of the database. This is especially important in real-world systems where different users require different levels of access.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F86jntr7g447ses7fb1os.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F86jntr7g447ses7fb1os.PNG" alt=" " width="603" height="600"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4kv4f30e0pk6tfuohnpc.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4kv4f30e0pk6tfuohnpc.PNG" alt=" " width="610" height="567"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Ensuring Atomicity in a Digital Wallet System</title>
      <dc:creator>Sri Mahalakshmi</dc:creator>
      <pubDate>Sun, 29 Mar 2026 09:01:45 +0000</pubDate>
      <link>https://dev.to/srimaha_17/ensuring-atomicity-in-a-digital-wallet-system-3jmh</link>
      <guid>https://dev.to/srimaha_17/ensuring-atomicity-in-a-digital-wallet-system-3jmh</guid>
      <description>&lt;p&gt;In digital wallet systems like PhonePe or GPay, it is important that transactions are handled correctly. When money is transferred from one user to another, both operations — deducting from the sender and adding to the receiver — must happen together. If one step fails, the entire transaction should fail. This is known as atomicity.&lt;/p&gt;

&lt;p&gt;To understand this, I used the accounts table with two users, Alice and Bob. Initially, their balances were 800 and 700.&lt;/p&gt;

&lt;p&gt;First, I performed a successful transaction where 200 was transferred from Alice to Bob. Inside a transaction block, I deducted 200 from Alice and added 200 to Bob, and then committed the transaction. After this, the balances were updated correctly to 600 for Alice and 900 for Bob.&lt;/p&gt;

&lt;p&gt;Next, I tested what happens when an error occurs during the transaction. I again started a transaction and deducted 200 from Alice. However, in the next step, I intentionally introduced an error in the update query for Bob. This caused the transaction to fail.&lt;/p&gt;

&lt;p&gt;Even though the deduction step was executed first, the database did not apply any changes permanently. After the failure, I checked the balances again, and they remained unchanged at 800 and 700.&lt;/p&gt;

&lt;p&gt;This shows that PostgreSQL does not allow partial updates in a transaction. Either all operations are completed successfully, or none of them are applied.&lt;/p&gt;

&lt;p&gt;From this experiment, it is clear that atomicity ensures reliability in financial systems. It prevents situations where money is deducted from one account but not added to another, maintaining correct and consistent data at all times.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbpkpkc66btcplytlgf9m.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbpkpkc66btcplytlgf9m.PNG" alt=" " width="668" height="413"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbmqyqgzfeucgaie85cw1.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbmqyqgzfeucgaie85cw1.PNG" alt=" " width="660" height="443"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Maintaining Consistency in a Digital Wallet System</title>
      <dc:creator>Sri Mahalakshmi</dc:creator>
      <pubDate>Sun, 29 Mar 2026 08:51:05 +0000</pubDate>
      <link>https://dev.to/srimaha_17/maintaining-consistency-in-a-digital-wallet-system-3alm</link>
      <guid>https://dev.to/srimaha_17/maintaining-consistency-in-a-digital-wallet-system-3alm</guid>
      <description>&lt;p&gt;In digital wallet applications like PhonePe or GPay, it is very important to maintain correct data at all times. Even a small mistake, such as allowing a negative balance, can lead to serious problems like incorrect transactions or money loss. This is where consistency in a database becomes important.&lt;/p&gt;

&lt;p&gt;To understand this, I used an accounts table with two users, Alice and Bob. After previous operations, their balances were 800 and 700.&lt;/p&gt;

&lt;p&gt;First, I tried to update Alice’s balance to a negative value directly. When I executed the query, PostgreSQL immediately gave an error and did not allow the update. This happened because of the constraint CHECK (balance &amp;gt;= 0) defined in the table. This constraint ensures that balance can never go below zero.&lt;/p&gt;

&lt;p&gt;Next, I tried to deduct more money than Alice had. Since her balance was 800, I attempted to subtract 1000. Again, PostgreSQL rejected the operation because it would result in a negative balance. The database prevented invalid data from being stored.&lt;/p&gt;

&lt;p&gt;I also tried performing this operation inside a transaction. Even in that case, the update failed and the transaction did not get committed. The database ensured that no incorrect changes were applied.&lt;/p&gt;

&lt;p&gt;After all these failed attempts, I checked the table again. The balances remained unchanged at 800 and 700. This shows that the database maintained a consistent and valid state throughout.&lt;/p&gt;

&lt;p&gt;From this experiment, it is clear that PostgreSQL enforces rules using constraints to prevent invalid data. At the same time, in real-world applications, the system should also check the balance before performing a transaction to avoid such errors.&lt;/p&gt;

&lt;p&gt;Overall, this shows how consistency is maintained by ensuring that only valid data is stored in the database.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwdn78ftnmpbf16qwu0wr.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwdn78ftnmpbf16qwu0wr.PNG" alt=" " width="800" height="401"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>backend</category>
      <category>database</category>
      <category>postgres</category>
      <category>sql</category>
    </item>
    <item>
      <title>Ensuring Durability in a Digital Wallet System Using PostgreSQL</title>
      <dc:creator>Sri Mahalakshmi</dc:creator>
      <pubDate>Sun, 29 Mar 2026 08:34:09 +0000</pubDate>
      <link>https://dev.to/srimaha_17/ensuring-durability-in-a-digital-wallet-system-using-postgresql-34j5</link>
      <guid>https://dev.to/srimaha_17/ensuring-durability-in-a-digital-wallet-system-using-postgresql-34j5</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fplfylk3oawesictuv1cs.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fplfylk3oawesictuv1cs.PNG" alt=" " width="800" height="438"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn1py1xssem793c09rafi.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn1py1xssem793c09rafi.PNG" alt=" " width="800" height="352"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In digital wallet applications, once a transaction is completed, users expect it to remain saved even if the system crashes or restarts. This requirement is handled by the durability property in database systems.&lt;/p&gt;

&lt;p&gt;To understand this, I performed a simple experiment using PostgreSQL.&lt;/p&gt;

&lt;p&gt;First, I created an accounts table and inserted two users: Alice with a balance of 1000 and Bob with a balance of 500. This represented the initial state of the system.&lt;/p&gt;

&lt;p&gt;Then, I performed a transaction to transfer 200 from Alice to Bob. Inside the transaction, 200 was deducted from Alice’s balance and added to Bob’s balance. After executing these operations, I committed the transaction. Once committed, the updated balances became 800 for Alice and 700 for Bob.&lt;/p&gt;

&lt;p&gt;To simulate a system restart, I closed the database session and reconnected again. After reconnecting, I checked the account balances using a select query. The balances remained unchanged at 800 and 700.&lt;/p&gt;

&lt;p&gt;This shows that once a transaction is committed, the changes are permanently stored in the database and are not lost, even after a restart. This property is known as durability.&lt;/p&gt;

&lt;p&gt;If a failure occurs before the commit, the changes will not be saved. But if the failure happens after the commit, the data remains safe and consistent.&lt;/p&gt;

&lt;p&gt;This experiment demonstrates how databases ensure reliability in real-world applications like digital payment systems, where maintaining correct and permanent transaction data is essential.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Alter Tables</title>
      <dc:creator>Sri Mahalakshmi</dc:creator>
      <pubDate>Thu, 26 Mar 2026 15:34:00 +0000</pubDate>
      <link>https://dev.to/srimaha_17/alter-tables-1kbh</link>
      <guid>https://dev.to/srimaha_17/alter-tables-1kbh</guid>
      <description>&lt;p&gt;&lt;code&gt;1. Make email NOT NULL in customers&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;ALTER TABLE customers&lt;br&gt;
ALTER COLUMN email SET NOT NULL;&lt;/p&gt;

&lt;p&gt;Ensures all future records must have an email.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;2. Make username unique in users&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;ALTER TABLE users ADD CONSTRAINT unique_username UNIQUE (username);&lt;/p&gt;

&lt;p&gt;Prevents duplicate usernames.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;3. Add CHECK on price in products&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;ALTER TABLE products ADD CONSTRAINT check_price CHECK (price &amp;gt; 0);&lt;/p&gt;

&lt;p&gt;Ensures price is always greater than 0.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;4. Set default status in orders&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;ALTER TABLE orders&lt;br&gt;
ALTER COLUMN status SET DEFAULT 'pending';&lt;/p&gt;

&lt;p&gt;Automatically assigns pending if no value is given.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;5. Add salary column with constraints&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;ALTER TABLE employees ADD COLUMN salary INT NOT NULL CHECK (salary &amp;gt; 10000);&lt;/p&gt;

&lt;p&gt;Ensures salary is mandatory and above 10,000.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;6. Add ON DELETE CASCADE to foreign key&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;ALTER TABLE employees DROP CONSTRAINT employees_department_id_fkey;&lt;/p&gt;

&lt;p&gt;ALTER TABLE employees ADD CONSTRAINT employees_department_id_fkey FOREIGN KEY (department_id) REFERENCES departments(id) ON DELETE CASCADE;&lt;/p&gt;

&lt;p&gt;Deletes employees automatically when a department is removed.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;7. Remove CHECK constraint on balance&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;ALTER TABLE accounts DROP CONSTRAINT accounts_balance_check;&lt;/p&gt;

&lt;p&gt;Removes restriction on balance.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;8. Add composite UNIQUE in payments&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;ALTER TABLE payments ADD CONSTRAINT unique_user_transaction UNIQUE (user_id, transaction_id);&lt;/p&gt;

&lt;p&gt;Ensures no duplicate transaction per user.&lt;/p&gt;

</description>
      <category>database</category>
      <category>postgres</category>
      <category>sql</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Create Tables</title>
      <dc:creator>Sri Mahalakshmi</dc:creator>
      <pubDate>Thu, 26 Mar 2026 15:30:41 +0000</pubDate>
      <link>https://dev.to/srimaha_17/create-tables-3gl</link>
      <guid>https://dev.to/srimaha_17/create-tables-3gl</guid>
      <description>&lt;p&gt;&lt;code&gt;1. Students table with unique id&lt;/code&gt;&lt;br&gt;
CREATE TABLE students ( id SERIAL PRIMARY KEY, name TEXT,age INT);&lt;/p&gt;

&lt;p&gt;&lt;code&gt;PRIMARY KEY ensures each student is uniquely identified.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;2. Employees table with required fields&lt;/code&gt;&lt;br&gt;
CREATE TABLE employees (id SERIAL PRIMARY KEY,name TEXT NOT NULL,email TEXT NOT NULL,phone_number TEXT);&lt;/p&gt;

&lt;p&gt;&lt;code&gt;NOT NULL ensures name and email cannot be empty, phone is optional.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;3. Users table with unique values&lt;/code&gt;&lt;br&gt;
CREATE TABLE users (id SERIAL PRIMARY KEY,username TEXT UNIQUE,email TEXT UNIQUE);&lt;/p&gt;

&lt;p&gt;&lt;code&gt;UNIQUE prevents duplicate usernames and emails.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;4. Products table with constraints&lt;/code&gt;&lt;br&gt;
CREATE TABLE products (id SERIAL PRIMARY KEY,name TEXT,price INT CHECK (price &amp;gt; 0),stock INT CHECK (stock &amp;gt;= 0));&lt;/p&gt;

&lt;p&gt;&lt;code&gt;CHECK ensures valid price and non-negative stock.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;5. Orders table with defaults&lt;/code&gt;&lt;br&gt;
CREATE TABLE orders (id SERIAL PRIMARY KEY,status TEXT DEFAULT 'pending',created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP);&lt;/p&gt;

&lt;p&gt;&lt;code&gt;DEFAULT assigns automatic values if none provided.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;6. Accounts table with rules&lt;/code&gt;&lt;br&gt;
CREATE TABLE accounts (id SERIAL PRIMARY KEY,account_number TEXT UNIQUE NOT NULL,balance INT CHECK (balance &amp;gt;= 0));&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Ensures valid account number and no negative balance.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;7. Enrollments with composite uniqueness&lt;/code&gt;&lt;br&gt;
CREATE TABLE enrollments (student_id INT,course_id INT,UNIQUE (student_id, course_id));&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Prevents duplicate enrollment for same student-course pair.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;8. Foreign key relationship&lt;/code&gt;&lt;br&gt;
CREATE TABLE departments (id SERIAL PRIMARY KEY,name TEXT);&lt;/p&gt;

&lt;p&gt;CREATE TABLE employees (id SERIAL PRIMARY KEY,name TEXT,department_id INT,FOREIGN KEY (department_id) REFERENCES departments(id));&lt;/p&gt;

&lt;p&gt;&lt;code&gt;FOREIGN KEY ensures employees belong to valid departments.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;9. Cascade update and delete&lt;/code&gt;&lt;br&gt;
CREATE TABLE employees (id SERIAL PRIMARY KEY,name TEXT,department_id INT,FOREIGN KEY (department_id) REFERENCES departments(id) ON DELETE CASCADE ON UPDATE CASCADE);&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ON DELETE CASCADE removes employees when a department is deleted.&lt;/code&gt;&lt;br&gt;
&lt;code&gt;ON UPDATE CASCADE updates department_id automatically.&lt;/code&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>database</category>
      <category>postgres</category>
      <category>sql</category>
    </item>
    <item>
      <title>Filter in DB</title>
      <dc:creator>Sri Mahalakshmi</dc:creator>
      <pubDate>Thu, 26 Mar 2026 15:07:37 +0000</pubDate>
      <link>https://dev.to/srimaha_17/filter-in-db-1pb</link>
      <guid>https://dev.to/srimaha_17/filter-in-db-1pb</guid>
      <description>&lt;p&gt;1.SELECT is used to choose what data to display.&lt;br&gt;
2.WHERE is used to filter records based on conditions.&lt;br&gt;
3.AND and OR are used to combine multiple conditions.&lt;br&gt;
4.ORDER BY is used to sort the data either ascending or descending.&lt;br&gt;
5.LIMIT is used to restrict how many rows are shown.&lt;br&gt;
6.OFFSET is used to skip a certain number of rows.&lt;br&gt;
7.BETWEEN is used to filter values within a range.&lt;br&gt;
8.IN is used to match multiple possible values.&lt;br&gt;
9.LIKE and SIMILAR TO are used for pattern matching in text.&lt;br&gt;
10.IS NULL is used to find missing or empty values.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;1. Get movies with rental rate greater than 3&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;SELECT title, rental_rate FROM film WHERE rental_rate &amp;gt; 3;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;2. Rental rate &amp;gt; 3 and replacement cost &amp;lt; 20&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;SELECT title, rental_rate, replacement_cost FROM film WHERE rental_rate &amp;gt; 3 AND replacement_cost &amp;lt; 20;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;3. Rated PG or rental rate 0.99&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;SELECT title, rating, rental_rate FROM film WHERE rating = 'PG' OR rental_rate = 0.99;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;4. Top 10 movies by rental rate&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;SELECT title, rental_rate FROM film ORDER BY rental_rate DESC LIMIT 10;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;5. Skip 5 and get next 3&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;SELECT title, rental_rate FROM film ORDER BY rental_rate ASC OFFSET 5 LIMIT 3;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;6. Skip 5 and get next 3&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;SELECT title, rental_rate FROM film ORDER BY rental_rate ASC OFFSET 5 FETCH NEXT 3 ROWS ONLY;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;7. Rental duration between 3 and 7&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;SELECT title, rental_duration FROM film WHERE rental_duration BETWEEN 3 AND 7;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;8. Title starts with A and ends with e&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;SELECT title FROM film WHERE title LIKE 'A%e';&lt;/p&gt;

&lt;p&gt;&lt;code&gt;9. Customers without email&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;SELECT first_name, last_name FROM customer WHERE email IS NULL;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;10. Movies from 2006 with conditions&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;SELECT title, rental_rate, release_year FROM film WHERE release_year = 2006 AND rental_rate IN (2.99, 3.99) AND title LIKE 'S%' LIMIT 5;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;11. Skip 20 customers, show next 10&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;SELECT first_name, last_name FROM customer ORDER BY last_name LIMIT 10 OFFSET 20;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;12. Highest replacement cost (skip first)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;SELECT title, replacement_cost FROM film ORDER BY replacement_cost DESC OFFSET 1 FETCH NEXT 5 ROWS ONLY;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;13. Rentals between dates&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;SELECT rental_id, rental_date, customer_id FROM rental WHERE rental_date BETWEEN '2005-05-01' AND '2005-06-01';&lt;/p&gt;

&lt;p&gt;&lt;code&gt;14. Actors with "man" in last name&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;SELECT first_name, last_name FROM actor WHERE last_name LIKE '%man%';&lt;/p&gt;

&lt;p&gt;&lt;code&gt;15. Movies with no special features&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;SELECT title FROM film WHERE special_features IS NULL;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;16. Rental duration more than 7&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;SELECT title, rental_duration FROM film WHERE rental_duration &amp;gt; 7;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;17. Movies with multiple conditions&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;SELECT title, rental_rate, rating FROM film WHERE rental_rate IN (2.99, 4.99) AND rating = 'R' AND title LIKE '%L%' LIMIT 10;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;18. Title starts with A or B and ends with s&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;SELECT title FROM film WHERE title SIMILAR TO '(A|B)%s';&lt;/p&gt;

&lt;p&gt;&lt;code&gt;19. Title contains Man, Men, or Woman&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;SELECT title FROM film WHERE title SIMILAR TO '%(Man|Men|Woman)%';&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>database</category>
      <category>sql</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Basic Select SQL Queries</title>
      <dc:creator>Sri Mahalakshmi</dc:creator>
      <pubDate>Thu, 26 Mar 2026 14:59:28 +0000</pubDate>
      <link>https://dev.to/srimaha_17/basic-select-sql-queries-emi</link>
      <guid>https://dev.to/srimaha_17/basic-select-sql-queries-emi</guid>
      <description>&lt;p&gt;The SELECT statement is used to choose what data we want, either all columns (*) or specific ones. &lt;/p&gt;

&lt;p&gt;The WHERE clause helps filter rows based on conditions like ID, country, or population.&lt;/p&gt;

&lt;p&gt;To avoid duplicate results, DISTINCT is used, while pattern matching with LIKE helps search data based on formats. Aggregate functions like COUNT are used to perform calculations on data.&lt;/p&gt;

&lt;p&gt;Overall idea&lt;br&gt;
SELECT - what you want&lt;br&gt;
FROM - where to get it&lt;br&gt;
WHERE - filter data&lt;br&gt;
DISTINCT - remove duplicates&lt;br&gt;
COUNT - calculate values&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzfsv6kb498mh6xnfzumg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzfsv6kb498mh6xnfzumg.png" alt=" " width="800" height="341"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjczdc54p9un9loenhlvm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjczdc54p9un9loenhlvm.png" alt=" " width="800" height="369"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyv5jfzzdn14y0f4gnrra.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyv5jfzzdn14y0f4gnrra.png" alt=" " width="800" height="312"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgl3rvfx8215a8af7ozg3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgl3rvfx8215a8af7ozg3.png" alt=" " width="800" height="292"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu0173o5nxabg5ewxlclh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu0173o5nxabg5ewxlclh.png" alt=" " width="800" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3fwt65qjbj5c7u3ouzm0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3fwt65qjbj5c7u3ouzm0.png" alt=" " width="800" height="281"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5fke1vr4govb0xv5use5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5fke1vr4govb0xv5use5.png" alt=" " width="800" height="290"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy5w8bl5hnxvlxaruytop.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy5w8bl5hnxvlxaruytop.png" alt=" " width="800" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fst0n3skjy9d8a1zi00ur.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fst0n3skjy9d8a1zi00ur.png" alt=" " width="800" height="429"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How a request originates from cllient and reaches the server ?</title>
      <dc:creator>Sri Mahalakshmi</dc:creator>
      <pubDate>Thu, 26 Mar 2026 14:44:31 +0000</pubDate>
      <link>https://dev.to/srimaha_17/how-a-request-originates-from-cllient-and-reaches-the-server--n02</link>
      <guid>https://dev.to/srimaha_17/how-a-request-originates-from-cllient-and-reaches-the-server--n02</guid>
      <description>&lt;p&gt;When a client sends a request, it starts by entering a URL like &lt;a href="http://www.example.com" rel="noopener noreferrer"&gt;www.example.com&lt;/a&gt;. The client first needs the IP address of that domain, so it performs DNS resolution. It checks local cache, then asks a DNS resolver, which eventually gets the IP from the authoritative server.&lt;/p&gt;

&lt;p&gt;Once the IP is obtained, the client creates a connection to the server using protocols like TCP (and HTTPS if secure). This happens through a process called a handshake, where both client and server agree to communicate.&lt;/p&gt;

&lt;p&gt;After the connection is established, the client sends an HTTP request to the server’s IP address. This request travels through multiple network devices such as routers and switches across the internet.&lt;/p&gt;

&lt;p&gt;Finally, the request reaches the server. The server processes it, prepares a respons, and sends it back to the client, which then displays it in the browser.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How DNS resolver is happening</title>
      <dc:creator>Sri Mahalakshmi</dc:creator>
      <pubDate>Thu, 26 Mar 2026 14:42:05 +0000</pubDate>
      <link>https://dev.to/srimaha_17/how-dns-resolver-is-happening-3af</link>
      <guid>https://dev.to/srimaha_17/how-dns-resolver-is-happening-3af</guid>
      <description>&lt;p&gt;The user makes a request, and a DNS query starts. First, it goes to the local machine resolver, where the system checks the cache (browser/OS). If the IP is already present, it returns immediately.&lt;/p&gt;

&lt;p&gt;If not found, the request goes through the internet (ISP) to the main resolver, usually the ISP or a public DNS. This resolver again checks its cache. If it has the IP, it returns it. If not, it starts the DNS lookup process.&lt;/p&gt;

&lt;p&gt;The resolver contacts the root server. The root server does not know the exact IP, but it knows where the TLD servers are, so it directs the resolver to the correct TLD (like .com, .org).&lt;/p&gt;

&lt;p&gt;Then the resolver asks the TLD server, which tells where the authoritative server for that domain is.&lt;/p&gt;

&lt;p&gt;Next, the resolver asks the authoritative server, which gives the final IP address.&lt;/p&gt;

&lt;p&gt;This IP is sent back to the resolver, then to the user’s system, and stored in cache for future use. Finally, the browser uses this IP to load the website.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hokmjfkufa9cwc7fe2a7.jpg" rel="noopener noreferrer"&gt;https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hokmjfkufa9cwc7fe2a7.jpg&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>computerscience</category>
      <category>networking</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Database- Querying and Filtering Data</title>
      <dc:creator>Sri Mahalakshmi</dc:creator>
      <pubDate>Tue, 24 Mar 2026 15:52:08 +0000</pubDate>
      <link>https://dev.to/srimaha_17/database-querying-and-filtering-data-2b34</link>
      <guid>https://dev.to/srimaha_17/database-querying-and-filtering-data-2b34</guid>
      <description>&lt;p&gt;&lt;code&gt;Database:&lt;/code&gt;&lt;br&gt;
   An organized collection of structured information.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Relational DB:&lt;/code&gt;&lt;br&gt;
  To have relationship between table [includes structured &amp;amp; unstructured] ,query alone differs.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Tasks:&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Retrieve film titles and their rental rates. Use column aliases to rename title as "Movie Title" and rental_rate as "Rate".&lt;/p&gt;

&lt;p&gt;I need only two columns which is title and rental_rate, and rename it as asked using AS.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT title AS "Movie Title", rental_rate AS "Rate" FROM film;&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;2.List customer names and their email addresses. Alias first_name and last_name as "First Name" and "Last Name".&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; We have first name, last name, and email,rename the first two using AS.

`` SELECT first_name AS "First Name", last_name AS "Last Name", email FROM customer;``
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;3.Get a list of films sorted by rental rate in descending order. If two films have the same rental rate, sort them alphabetically by title.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  Sort by rental rate descending,if two values are same then sort by title in ascending.

  ``SELECT title, rental_rate FROM film ORDER BY rental_rate DESC, title ASC;``
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;4.Retrieve actor names sorted by last name, then first name.&lt;br&gt;
      Sort by last_name first, then first_name.&lt;br&gt;
     &lt;code&gt;SELECT first_name, last_name FROM actor ORDER BY last_name, first_name;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;5.List all unique replacement costs from the film table.&lt;br&gt;
     If Duplicates exist, then use DISTINCT for unique values.&lt;br&gt;
    &lt;code&gt;SELECT DISTINCT replacement_cost FROM film;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;6.List all films' title and length in minutes. Alias length as "Duration (min)".&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Rename length to Duration(min) and list out the titles from film
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;code&gt;SELECT title, length AS "Duration (min)" FROM film;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;7.Retrieve customer first and last names along with their active status. Alias active as "Is Active".&lt;/p&gt;

&lt;p&gt;Retrieve first and last name and also rename active using AS.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT first_name, last_name, active AS "Is Active" FROM customer;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;8.Retrieve the list of film categories sorted alphabetically.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  Categories are in category table, sort it by name.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;code&gt;SELECT name FROM category ORDER BY name;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;9.List films by length, sorted in descending order. Include only the title and length.&lt;/p&gt;

&lt;p&gt;Longest(lengthy) movies first,use desc,retrieve title also from film.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT title, length FROM film ORDER BY length DESC;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;10.Retrieve all actor names, sorted by their first name in descending order.&lt;br&gt;
        Reverse alphabetical order in first name from actor.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT first_name, last_name FROM actor ORDER BY first_name DESC;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;11.List all unique ratings available in the film table.&lt;/p&gt;

&lt;p&gt;Using distinct we can retrieve unique values.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT DISTINCT rating FROM film;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;12.Find all unique rental durations from the film table.&lt;br&gt;
     Use distinct for unique values.&lt;br&gt;
&lt;code&gt;SELECT DISTINCT rental_duration FROM film;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;13.Retrieve the first unique customer ID based on active status. Include the customer_id and active columns, and order by customer_id.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT DISTINCT customer_id, active FROM customer ORDER BY customer_id;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;14.List the earliest rental date for each customer. Include customer_id and rental_date, and order by customer_id.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT customer_id, MIN(rental_date) AS rental_date FROM rental GROUP BY customer_id ORDER BY customer_id;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;15.List the 10 shortest films by length. Include the title and length.&lt;br&gt;
         For short size files listing we can use limit .&lt;br&gt;
&lt;code&gt;SELECT title, length FROM film ORDER BY length ASC LIMIT 10;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;16.Get the top 5 customers with the highest customer_id. Include the first and last name.&lt;br&gt;
             By using limit we get top specific elements.&lt;br&gt;
&lt;code&gt;SELECT first_name, last_name FROM customer ORDER BY customer_id DESC LIMIT 5;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;17.Retrieve all unique values of store_id from the inventory table.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT DISTINCT store_id FROM inventory;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;18.Find all unique replacement_cost values in the film table. Sort the results in ascending order.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT DISTINCT replacement_cost FROM film ORDER BY replacement_cost ASC;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;19.List the first rental date for each store. Include store_id and rental_date, and sort by store_id.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT store_id, MIN(rental_date) AS rental_date FROM rental GROUP BY store_id ORDER BY store_id;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;20.Retrieve a list of film ratings sorted alphabetically and include only unique values.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT DISTINCT rating FROM film ORDER BY rating;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;21.List films by rating in ascending order and length in descending order.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT title, rating, length FROM film ORDER BY rating ASC, length DESC;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;22.Retrieve actor names sorted by last_name in ascending order and first_name in descending order.&lt;br&gt;
    We can use asc,desc for sorting.&lt;br&gt;
&lt;code&gt;SELECT first_name, last_name FROM actor ORDER BY last_name ASC, first_name DESC;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;23.List films ordered by replacement_cost in ascending order and rental_rate in descending order.&lt;br&gt;
       list out all films ordered by replacement cost in asc and rental rate using desc&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT title, replacement_cost, rental_rate FROM film ORDER BY replacement_cost ASC, rental_rate DESC;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;24.Retrieve customer names sorted by last_name ascending and first_name descending.&lt;br&gt;
      list out first name and last name from customer ordered by asc for last name and desc in first name.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT first_name, last_name FROM customer ORDER BY last_name ASC, first_name DESC;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;25.List all rentals sorted by customer_id ascending and rental_date descending.&lt;br&gt;
       using asc and desc sort the customer id and rental date from rental.&lt;br&gt;
&lt;code&gt;SELECT customer_id, rental_date FROM rental ORDER BY customer_id ASC, rental_date DESC;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;26.Retrieve a list of films ordered by rental_duration ascending and title descending.&lt;br&gt;
   using asc ,desc order the rental_duration and title from film.&lt;br&gt;
&lt;code&gt;SELECT title FROM film ORDER BY rental_duration ASC, title DESC;&lt;/code&gt;&lt;/p&gt;

</description>
      <category>database</category>
      <category>sql</category>
      <category>data</category>
    </item>
  </channel>
</rss>
