A company wants to store their invoices in a database. They
already have their customers and articles in that database.
Both customer and article are each identified by an unique
integer value. Please create the SQL statements for
creating the necessary table(s) for storing the invoices in
a MySQL database. An invoice should hold information like
invoice number, customer, date, article(s) and quantity
etc.
Answer Posted / frank
Assume existing tables for customer and article are:
customers
+------------+----------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra
|
+------------+----------+------+-----+---------+----------------+
| customerId | int(11) | NO | PRI | NULL |
auto_increment |
| customer | char(50) | NO | | NULL |
|
+------------+----------+------+-----+---------+----------------+
article:
+-----------+----------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+----------+------+-----+---------+----------------+
| articleId | int(11) | NO | PRI | NULL | auto_increment |
| article | char(50) | NO | | NULL | |
+-----------+----------+------+-----+---------+----------------+
CREATE TABLE invoices (invoiceId INT AUTO_INCREMENT PRIMARY
KEY,customerId INT NOT NULL,articleId INT NOT
NULL,invoiceNumber CHAR(20) NOT NULL UNIQUE,invoiceDate DATE
NOT NULL,quantity INT NOT
NULL,INDEX(customerId),INDEX(articleId));
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
Can you tell how many values can set the function of mysql to consider?
What is the use of i-am-a-dummy flag in mysql?
How do I change mysql password?
Is mysql open source?
How is oracle different from mysql?
What are date and time functions in mysql?
How do I select a database in mysql?
What are procedures in mysql?
How do you concatenate strings in mysql?
How to rename an existing column in a table?
What is meant by decimal (5,2)?
change column name and make a unique column so we get no dupes.
What is the difference between mysql and sql?
How do I start mysql in ubuntu?
What is the function of myisamchk?