DATABASE LAB MID KEY
DATABASE LAB MID KEY
FROM EmployeeInfo
GROUP BY Gender;
Q5. How do you read the last five records from a database
using a SQL query?
To retrieve the last five records from a database using a SQL query, you can
use the ORDER BY clause combined with LIMIT. Here’s an example query:
SELECT *
FROM your_table
ORDER BY id DESC
LIMIT 5;
Q6. Update the column NAME and set the value to ‘Nitin’ in
the rows where the Age is 22
UPDATE Customer
SET CustomerName = 'Nitin'
WHERE Age = 22;
Q2. Binary Relationship with 1:1 cardinality with total participation of an entity
First Convert each entity and relationship to tables. Person
table corresponds to Person Entity with key as Per-Id. Similarly
Passport table corresponds to Passport Entity with key as Pass-No.
Has Table represents relationship between Person and Passport
(Which person has which passport). So it will take attribute Per-Id
from Person and Pass-No from Passport.
As we can see from Table 1, each Per-Id and Pass-No has only one
entry in Has Table. So we can merge all three tables into 1 with
attributes shown in Table 2. Each Per-Id will be unique and not null.
So it will be the key. Pass-No can’t be key because for some
person, it can be NULL.
UPS prides itself on having up-to-date information on the processing and current location of each
shipped item. To do this, UPS relies on a company-wide information system. Shipped items are
the heart of the UPS product tracking information system. Shipped items can be characterized
by item number (unique), weight, dimensions, insurance amount, destination, and final delivery
date. Shipped items are received into the UPS system at a single retail center. Retail centers are
characterized by their type, uniqueID, and address. Shipped items make their way to their
destination via one or more standard UPS transportation events (i.e., flights, truck deliveries).
These transportation events are characterized by a unique scheduleNumber, a type (e.g, flight,