Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GoikLectures
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Goik Martin
GoikLectures
Commits
a0528191
Commit
a0528191
authored
9 years ago
by
Goik Martin
Browse files
Options
Downloads
Patches
Plain Diff
Inserted data now matches schema
parent
f8b52d95
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
P/Sda1/catalog2rdbms/schema.sql
+16
-11
16 additions, 11 deletions
P/Sda1/catalog2rdbms/schema.sql
with
16 additions
and
11 deletions
P/Sda1/catalog2rdbms/schema.sql
+
16
−
11
View file @
a0528191
...
...
@@ -5,24 +5,29 @@ CREATE TABLE Product (
id
INTEGER
NOT
NULL
PRIMARY
KEY
,
name
VARCHAR
(
255
)
NOT
NULL
,
age
SMALLINT
)
ENGINE
=
InnoDB
;
);
CREATE
TABLE
Description
(
product
INTEGER
NOT
NULL
,
orderIndex
int
NOT
NULL
-- preserving the order of descriptions belonging to a given product
,
orderIndex
int
NOT
NULL
-- preserving the order of
multiple
descriptions belonging to a given product
,
text
VARCHAR
(
255
)
NOT
NULL
,
UNIQUE
(
product
,
orderIndex
)
,
UNIQUE
(
product
,
orderIndex
)
,
FOREIGN
KEY
(
product
)
REFERENCES
Product
(
id
)
)
ENGINE
=
InnoDB
;
);
-- example data corresponding to products.xml --
-- Product lacking age property --
INSERT
INTO
Product
(
id
,
name
)
VALUES
(
'mpt'
,
'Monkey Picked Tea'
);
INSERT
INTO
Description
VALUES
(
'mpt'
,
0
,
'Picked only by specially trained monkeys'
);
INSERT
INTO
Description
VALUES
(
'mpt'
,
1
,
'Rare wild Chinese tea'
);
INSERT
INTO
Product
(
id
,
name
)
VALUES
(
1
,
'Monkey Picked Tea'
);
INSERT
INTO
Description
VALUES
(
1
,
0
,
'Picked only by specially trained monkeys'
);
INSERT
INTO
Description
VALUES
(
1
,
1
,
'Rare wild Chinese tea'
);
INSERT
INTO
Product
VALUES
(
'instantTent'
,
'4-Person Instant Tent'
,
15
);
INSERT
INTO
Description
VALUES
(
'instantTent'
,
0
,
'Exclusive WeatherTec system.'
);
INSERT
INTO
Description
VALUES
(
'instantTent'
,
1
,
'4-person, 1-room tent'
);
INSERT
INTO
Description
VALUES
(
'instantTent'
,
2
,
'Pre-attached tent poles'
);
INSERT
INTO
Product
VALUES
(
2
,
'4-Person Instant Tent'
,
15
);
INSERT
INTO
Description
VALUES
(
2
,
0
,
'Exclusive WeatherTec system.'
);
INSERT
INTO
Description
VALUES
(
2
,
1
,
'4-person, 1-room tent'
);
INSERT
INTO
Description
VALUES
(
2
,
2
,
'Pre-attached tent poles'
);
SELECT
*
FROM
Product
;
-- this should fail due to a foreign key constraint: --
DELETE
FROM
Product
WHERE
id
=
1
;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment