Mis Odd Question
Mis Odd Question
author_id INT,
genre VARCHAR(50),
published_date DATE,
);
-- Authors table
bio TEXT
);
-- Customers table
phone VARCHAR(20),
address TEXT
);
-- Orders table
customer_id INT,
order_date DATE,
-- Order_Items table
order_id INT,
book_id INT,
quantity INT,
);
-- Sample Data
INSERT INTO Authors (author_id, name, bio) VALUES (1, 'Author A', 'Bio of Author A');
INSERT INTO Books (book_id, title, author_id, genre, price, published_date) VALUES (1, 'Book A', 1, 'Fiction', 19.99,
'2023-01-01');
INSERT INTO Customers (customer_id, name, email, phone, address) VALUES (1, 'Customer A',
'customer.a@example.com', '123-456-7890', '123 Street, City, Country');
INSERT INTO Orders (order_id, customer_id, order_date, total_amount) VALUES (1, 1, '2024-08-01', 19.99);
INSERT INTO Order_Items (order_item_id, order_id, book_id, quantity, price) VALUES (1, 1, 1, 1, 19.99);
3. Normalization to Third Normal Form (3NF)
Ensure that the table has no repeating groups. The unnormalized table already meets this requirement.
Remove partial dependencies. We separate the data into multiple tables to ensure each non-key attribute is fully
functionally dependent on the primary key.
Customers Table:
1 Alice alice@example.com
2 Bob bob@example.com
Orders Table:
1 1 2024-08-01
2 2 2024-08-02
3 1 2024-08-03
Books Table:
1 Book A 1 10.00
2 Book B 2 15.00
3 Book C 1 20.00
Authors Table:
AuthorID AuthorName
1 Author A
2 Author B
Remove transitive dependencies. Each non-key attribute should depend only on the primary key.
5. SQL Joins
INNER JOIN: Returns only the rows where there is a match in both tables.
sql
Copy code
FROM Customers
LEFT JOIN: Returns all rows from the left table and matched rows from the right table. If no match, NULL
values are returned.
sql
Copy code
FROM Customers
RIGHT JOIN: Returns all rows from the right table and matched rows from the left table. If no match, NULL
values are returned.
sql
Copy code
FROM Customers
Differences:
LEFT JOIN includes all records from the left table, with NULL for unmatched records in the right table.
RIGHT JOIN includes all records from the right table, with NULL for unmatched records in the left table.
Entities:
Relationships:
User Interface: The frontend through which users interact with the CRM, including web and mobile
applications.
Application Server: Handles business logic, processes user requests, and communicates with the database.
May include components like authentication, API gateway, and service layer.
Database Server: Stores and manages customer data, interactions, and transactional records. It can include
relational databases, data warehouses, and NoSQL databases for different data types.
Stored Procedure:
sql
Copy code
CREATE PROCEDURE GetTotalSalesByMonth(IN year INT, IN month INT, OUT total_sales DECIMAL(10, 2))
BEGIN
SELECT SUM(total_amount)
INTO total_sales
FROM Orders
END;
sql
Copy code
A form can be created in the database management system (DBMS) or a web application with fields for Name, Email,
Phone, and Address.
sql
Copy code
FROM Customers;
Example:
Editor: Can insert, update, and delete records but cannot alter table structures.
Implementation:
sql
Copy code
-- Create roles
-- Assign privileges
sql
Copy code
Explanation: Indexing speeds up query performance by allowing the database to find records faster. It works similarly
to an index in a book. However, indexes consume additional disk space and may slow down INSERT, UPDATE, and
DELETE operations due to the overhead of maintaining the index.
Key Challenges:
Data migration
User training
Change management
Benefits:
Phases:
1. Planning: Define objectives, scope, and requirements. Conduct feasibility studies and risk assessments.
2. Design: Develop system architecture, design database schema, and define interfaces.
4. Testing: Perform unit, integration, and user acceptance testing to ensure system functionality and reliability.
5. Deployment: Implement the system in the production environment, provide training, and roll out the system
to users.