


















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



















Qualification TEC Level 5 HND Diploma in Computing
Unit number and title Unit 04: Database Design & Development
Submission date Date Received 1st submission
Re-submission Date Date Received 2nd submission
Student Name Le Minh Hoang Student ID GCH
Class GCH1101^ Assessor name Lecture^ Manh
Student declaration
I certify that the assignment submission is entirely my own work and I fully understand the consequences of plagiarism. I understand that
making a false declaration is a form of malpractice.
Student’s signature hoang
Grading grid
Grade: Assessor Signature: Date:
Signature & Date:
can have many Foreign Keys
Producer
Orders
Customer
Database named Lmh
Creat databese
CREATE DATABASE [Lmh] CONTAINMENT = NONE ON PRIMARY ( NAME = N'Lmh', FILENAME = N'E:\SQL server\MSSQL14.SQLEXPRESS\MSSQL\DATA\Lmh.mdf' , SIZE = 8192KB , MAXSIZE = UNLIMITED, FILEGROWTH = 65536KB ) LOG ON ( NAME = N'Lmh_log', FILENAME = N'E:\SQL server\MSSQL14.SQLEXPRESS\MSSQL\DATA\Lmh_log.ldf' , SIZE = 8192KB , MAXSIZE = 2048GB , FILEGROWTH = 65536KB ) GO
o Result
Customers table
CREATE TABLE [dbo].[Customers]( [CustomerID] [int] NOT NULL, [CustomerFirstName] nvarchar NOT NULL, [CustomerLastName] nvarchar NULL, [CustomerAddress] nvarchar NOT NULL, [CustomerPassword] nvarchar NOT NULL, CONSTRAINT [PK_Customers] PRIMARY KEY CLUSTERED ( [CustomerID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO
o Result
Items table
CREATE TABLE [dbo].[Items]( [itemID] [int] NOT NULL, [itemName] nvarchar NOT NULL, [ProducerID] [int] NOT NULL, [ItemDetail_ID] [int] NOT NULL, CONSTRAINT [PK_Items] PRIMARY KEY CLUSTERED ( [itemID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO
o Result
Item detail table
CREATE TABLE [dbo].[ItemDetail]( [ItemDetail_ID] [int] NOT NULL, [ItemNote] nvarchar NULL, [ItemPrice] [int] NOT NULL, CONSTRAINT [PK_ItemDetail] PRIMARY KEY CLUSTERED ( [ItemDetail_ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO
o Result
Feedback table
CREATE TABLE [dbo].[Feedback]( [FeedbackID] [int] NOT NULL, [Feedback_Detail] nvarchar NULL, [CustomerID] [int] NOT NULL, [itemID] [int] NOT NULL, CONSTRAINT [PK_Feedback] PRIMARY KEY CLUSTERED ( [FeedbackID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO
o Result
Customers
INSERT INTO [dbo].[Customers] ([CustomerID] ,[CustomerFirstName] ,[CustomerLastName] ,[CustomerAddress] ,[CustomerPassword] ) VALUES ('105','Hoang','Phong','Hai Phong','555')
o Result
Item Detail
INSERT INTO [dbo].[ItemDetail] ([ItemDetail_ID] ,[ItemNote] ,[ItemPrice]) VALUES ('4','oke','1200')
o Result
Feedback
INSERT INTO [dbo].[Feedback] ([FeedbackID] ,[Feedback_Detail] ,[CustomerID] ,[itemID]) VALUES ('4','Good standards','104','4')
o Result
Orders
INSERT INTO [dbo].[Orders] ([OrderID] ,[Order_item] ,[Order_quantity] ,[Order_price] ,[Order_total] ,[itemID] ,[CustomerID]) VALUES ('1','iphone14','1','1000','1000','1','101')
o Result
This is a simple update statement with the table name and the information of a column in the table. In the above example, updating the Feedback table with Feedback_ID = 1 will update the Detail of the Feedback with that ID number 1 to 'This product good enough for me”.
Before
After
Querry data in Customer Table
Querry data in ItemDetail Table
Querry data in Producer Table
A trigger is a stored procedure in database which automatically invokes whenever a special event in the database occurs. For example, a trigger can be invoked when a row is inserted into a specified table or when certain table columns are being updated. Suppose, an application needs to insert new members, then the data should be stored in a table called "customer_approvals” so that it can be approved before inserting into the "customer" table. First, we need to create a view named “view_customer” to insert new customer. Customer inserted into the view will be triggered to insert Customer into the “customer_approvals” table by a "trigger". Below are the specific images.
"customer_approvals" table. Query data from VIEW "view_customer" then new records will appeal